1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Cleanup error handling in irssi_ssl_{read,write}. Return G_IO_STATUS_AGAIN if

openssl error is SSL_WANT_{READ,WRITE}, G_IO_STATUS_ERROR otherwise.


git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@4883 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Emanuele Giaquinta 2008-11-02 14:02:00 +00:00 committed by exg
parent f8461d39bc
commit fc85d71d12

View File

@ -93,22 +93,6 @@ static gboolean irssi_ssl_verify(SSL *ssl, SSL_CTX *ctx, X509 *cert)
return TRUE; return TRUE;
} }
static GIOStatus ssl_errno(gint e)
{
switch(e)
{
case EINVAL:
return G_IO_STATUS_ERROR;
case EINTR:
case EAGAIN:
return G_IO_STATUS_AGAIN;
default:
return G_IO_STATUS_ERROR;
}
/*UNREACH*/
return G_IO_STATUS_ERROR;
}
static GIOStatus irssi_ssl_read(GIOChannel *handle, gchar *buf, gsize len, gsize *ret, GError **gerr) static GIOStatus irssi_ssl_read(GIOChannel *handle, gchar *buf, gsize len, gsize *ret, GError **gerr)
{ {
GIOSSLChannel *chan = (GIOSSLChannel *)handle; GIOSSLChannel *chan = (GIOSSLChannel *)handle;
@ -118,9 +102,10 @@ static GIOStatus irssi_ssl_read(GIOChannel *handle, gchar *buf, gsize len, gsize
if(err < 0) if(err < 0)
{ {
*ret = 0; *ret = 0;
if(SSL_get_error(chan->ssl, err) == SSL_ERROR_WANT_READ) err = SSL_get_error(chan->ssl, err);
if(err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE)
return G_IO_STATUS_AGAIN; return G_IO_STATUS_AGAIN;
return ssl_errno(errno); return G_IO_STATUS_ERROR;
} }
else else
{ {
@ -140,9 +125,10 @@ static GIOStatus irssi_ssl_write(GIOChannel *handle, const gchar *buf, gsize len
if(err < 0) if(err < 0)
{ {
*ret = 0; *ret = 0;
if(SSL_get_error(chan->ssl, err) == SSL_ERROR_WANT_READ) err = SSL_get_error(chan->ssl, err);
if(err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE)
return G_IO_STATUS_AGAIN; return G_IO_STATUS_AGAIN;
return ssl_errno(errno); return G_IO_STATUS_ERROR;
} }
else else
{ {