From 13d3299816ffb5de07c2178a83af7661d63e1dea Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sat, 12 Jul 2014 22:54:35 +0200
Subject: Fix connection abortion
---
src/kike.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/kike.c b/src/kike.c
index 2b10835..80e554c 100644
--- a/src/kike.c
+++ b/src/kike.c
@@ -381,7 +381,7 @@ static bool
irc_try_read (struct connection *conn)
{
// TODO
- return false;
+ return true;
}
static bool
@@ -413,7 +413,7 @@ irc_try_read_ssl (struct connection *conn)
return true;
case SSL_ERROR_WANT_WRITE:
conn->ssl_rx_want_tx = true;
- return false;
+ return true;
case XSSL_ERROR_TRY_AGAIN:
continue;
default:
@@ -428,7 +428,7 @@ static bool
irc_try_write (struct connection *conn)
{
// TODO
- return false;
+ return true;
}
static bool
@@ -456,7 +456,7 @@ irc_try_write_ssl (struct connection *conn)
return true;
case SSL_ERROR_WANT_READ:
conn->ssl_tx_want_rx = true;
- return false;
+ return true;
case XSSL_ERROR_TRY_AGAIN:
continue;
default:
@@ -483,13 +483,13 @@ on_irc_client_ready (const struct pollfd *pfd, void *user_data)
conn->initialized = true;
}
- // FIXME: aborting a connection inside try_read() will fuck things up
int new_events = 0;
if (conn->ssl)
{
// Reads may want to write, writes may want to read, poll() may
// return unexpected things in `revents'... let's try both
- irc_try_read_ssl (conn) && irc_try_write_ssl (conn);
+ if (!irc_try_read_ssl (conn) || !irc_try_write_ssl (conn))
+ return;
new_events |= POLLIN;
if (conn->write_buffer.len || conn->ssl_rx_want_tx)
@@ -501,7 +501,8 @@ on_irc_client_ready (const struct pollfd *pfd, void *user_data)
}
else
{
- irc_try_read (conn) && irc_try_write (conn);
+ if (!irc_try_read (conn) || !irc_try_write (conn))
+ return;
new_events |= POLLIN;
if (conn->write_buffer.len)
--
cgit v1.2.3-70-g09d2