Mercurial > gftp.yaz
diff lib/sslcommon.c @ 546:5d13fa48c275
2004-9-6 Brian Masney <masneyb@gftp.org>
* lib/protocols.c lib/sshv2.c lib/sslcommon.c - cleanups to the
functions that write/read to/from the network. Retry the operation
if EAGAIN is returned
* lib/ftps.c - return an error if the SSL session cannot be setup
properly
author | masneyb |
---|---|
date | Wed, 08 Sep 2004 00:18:10 +0000 |
parents | 075f89b4395c |
children | 4ad80d524dda |
line wrap: on
line diff
--- a/lib/sslcommon.c Tue Sep 07 23:30:40 2004 +0000 +++ b/lib/sslcommon.c Wed Sep 08 00:18:10 2004 +0000 @@ -408,6 +408,8 @@ ssize_t ret; int err; + g_return_val_if_fail (request->ssl != NULL, GFTP_EFATAL); + if (!gftp_ssl_initialized) { request->logging_function (gftp_logging_error, request, @@ -422,13 +424,16 @@ if ((ret = SSL_read (request->ssl, ptr, size)) < 0) { err = SSL_get_error (request->ssl, ret); - if (errno == EINTR) + if (errno == EINTR || errno == EAGAIN) { if (request->cancel) - break; - else - continue; - } + { + gftp_disconnect (request); + return (GFTP_ERETRYABLE); + } + + continue; + } request->logging_function (gftp_logging_error, request, _("Error: Could not read from socket: %s\n"), @@ -437,14 +442,10 @@ return (GFTP_ERETRYABLE); } + + break; } - while (errno == EINTR && !(request != NULL && request->cancel)); - - if (errno == EINTR && request != NULL && request->cancel) - { - gftp_disconnect (request); - return (GFTP_ERETRYABLE); - } + while (1); return (ret); } @@ -455,6 +456,8 @@ { size_t ret, w_ret; + g_return_val_if_fail (request->ssl != NULL, GFTP_EFATAL); + if (!gftp_ssl_initialized) { request->logging_function (gftp_logging_error, request, @@ -468,12 +471,15 @@ w_ret = SSL_write (request->ssl, ptr, size); if (w_ret <= 0) { - if (errno == EINTR) + if (errno == EINTR || errno == EAGAIN) { if (request != NULL && request->cancel) - break; - else - continue; + { + gftp_disconnect (request); + return (GFTP_ERETRYABLE); + } + + continue; } request->logging_function (gftp_logging_error, request, @@ -483,18 +489,13 @@ return (GFTP_ERETRYABLE); } + ptr += w_ret; size -= w_ret; ret += w_ret; } while (size > 0); - if (errno == EINTR && request != NULL && request->cancel) - { - gftp_disconnect (request); - return (GFTP_ERETRYABLE); - } - return (ret); }