summaryrefslogtreecommitdiff
path: root/src/kike.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-07-12 22:54:35 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2014-07-12 22:54:35 +0200
commit13d3299816ffb5de07c2178a83af7661d63e1dea (patch)
tree98bc1ed4ecc04a705c20ad4c404b4ff06794c004 /src/kike.c
parentcdaab8fdf05f01181c58f77af2bb858fc366f7fa (diff)
downloadxK-13d3299816ffb5de07c2178a83af7661d63e1dea.tar.gz
xK-13d3299816ffb5de07c2178a83af7661d63e1dea.tar.xz
xK-13d3299816ffb5de07c2178a83af7661d63e1dea.zip
Fix connection abortion
Diffstat (limited to 'src/kike.c')
-rw-r--r--src/kike.c15
1 files 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)