Fix connection abortion

This commit is contained in:
Přemysl Eric Janouch 2014-07-12 22:54:35 +02:00
parent cdaab8fdf0
commit 13d3299816

View File

@ -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)