diff options
author | Emanuele Giaquinta <exg@irssi.org> | 2008-11-02 14:02:00 +0000 |
---|---|---|
committer | exg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2008-11-02 14:02:00 +0000 |
commit | fc85d71d12340a8e4de6523db19cf9dff7d889e4 (patch) | |
tree | afa13f201911576feecd00c5db27f312e8f07a64 /src/core | |
parent | f8461d39bc5bfd3efe908924c09d661756e447a1 (diff) | |
download | irssi-fc85d71d12340a8e4de6523db19cf9dff7d889e4.zip |
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
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/network-openssl.c | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/src/core/network-openssl.c b/src/core/network-openssl.c index f1c43075..219e6a5b 100644 --- a/src/core/network-openssl.c +++ b/src/core/network-openssl.c @@ -93,22 +93,6 @@ static gboolean irssi_ssl_verify(SSL *ssl, SSL_CTX *ctx, X509 *cert) 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) { GIOSSLChannel *chan = (GIOSSLChannel *)handle; @@ -118,9 +102,10 @@ static GIOStatus irssi_ssl_read(GIOChannel *handle, gchar *buf, gsize len, gsize if(err < 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 ssl_errno(errno); + return G_IO_STATUS_ERROR; } else { @@ -140,9 +125,10 @@ static GIOStatus irssi_ssl_write(GIOChannel *handle, const gchar *buf, gsize len if(err < 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 ssl_errno(errno); + return G_IO_STATUS_ERROR; } else { |