[glib-networking/wip/openssl] Retry read or write if we would block
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/wip/openssl] Retry read or write if we would block
- Date: Thu, 21 Jan 2016 09:23:24 +0000 (UTC)
commit bb569ef5bc57a1d54ad6896d906565e40e921188
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Thu Jan 21 10:21:58 2016 +0100
Retry read or write if we would block
If the socket would block we need to let the mainloop to
reiterate to let the socket go in a proper state instead
of trying again and end up in an infinite loop.
tls/openssl/gtlsbio.c | 18 ++++++------------
tls/openssl/gtlsconnection-openssl.c | 8 +++++---
2 files changed, 11 insertions(+), 15 deletions(-)
---
diff --git a/tls/openssl/gtlsbio.c b/tls/openssl/gtlsbio.c
index 0a3860c..13f9712 100644
--- a/tls/openssl/gtlsbio.c
+++ b/tls/openssl/gtlsbio.c
@@ -131,12 +131,9 @@ gtls_bio_write (BIO *bio,
if (written == -1)
{
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
- {
- BIO_set_retry_write (bio);
- g_error_free (error);
- }
- else
- g_propagate_error (gbio->write_error, error);
+ BIO_set_retry_write (bio);
+
+ g_propagate_error (gbio->write_error, error);
}
return written;
@@ -165,12 +162,9 @@ gtls_bio_read (BIO *bio,
if (read == -1)
{
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
- {
- BIO_set_retry_read (bio);
- g_error_free (error);
- }
- else
- g_propagate_error (gbio->read_error, error);
+ BIO_set_retry_read (bio);
+
+ g_propagate_error (gbio->read_error, error);
}
return read;
diff --git a/tls/openssl/gtlsconnection-openssl.c b/tls/openssl/gtlsconnection-openssl.c
index 3792ccd..ad10ee1 100644
--- a/tls/openssl/gtlsconnection-openssl.c
+++ b/tls/openssl/gtlsconnection-openssl.c
@@ -96,14 +96,16 @@ end_openssl_io (GTlsConnectionOpenssl *openssl,
err_code = SSL_get_error (ssl, ret);
- if (err_code == SSL_ERROR_WANT_READ ||
- err_code == SSL_ERROR_WANT_WRITE)
+ status = g_tls_connection_base_pop_io (tls, direction, ret > 0, &my_error);
+
+ if ((err_code == SSL_ERROR_WANT_READ ||
+ err_code == SSL_ERROR_WANT_WRITE) &&
+ status != G_TLS_CONNECTION_BASE_WOULD_BLOCK)
return G_TLS_CONNECTION_BASE_TRY_AGAIN;
if (err_code == SSL_ERROR_ZERO_RETURN)
return G_TLS_CONNECTION_BASE_OK;
- status = g_tls_connection_base_pop_io (tls, direction, ret > 0, &my_error);
if (status == G_TLS_CONNECTION_BASE_OK ||
status == G_TLS_CONNECTION_BASE_WOULD_BLOCK ||
status == G_TLS_CONNECTION_BASE_TIMED_OUT)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]