Mercurial > gftp.yaz
diff lib/protocols.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 | fd9ce7797984 |
children | 34a3f10d8bae |
line wrap: on
line diff
--- a/lib/protocols.c Tue Sep 07 23:30:40 2004 +0000 +++ b/lib/protocols.c Wed Sep 08 00:18:10 2004 +0000 @@ -2487,19 +2487,22 @@ errno = 0; ret = 0; - while (1) + do { FD_ZERO (&fset); FD_SET (fd, &fset); tv.tv_sec = network_timeout; tv.tv_usec = 0; ret = select (fd + 1, &fset, NULL, NULL, &tv); - if (ret == -1 && errno == EINTR) + if (ret == -1 && (errno == EINTR || errno == EAGAIN)) { - if (request && request->cancel) - break; - else - continue; + if (request != NULL && request->cancel) + { + gftp_disconnect (request); + return (GFTP_ERETRYABLE); + } + + continue; } else if (ret <= 0) { @@ -2510,17 +2513,21 @@ request->hostname); gftp_disconnect (request); } + return (GFTP_ERETRYABLE); } if ((ret = read (fd, ptr, size)) < 0) { - if (errno == EINTR) + if (errno == EINTR || errno == EAGAIN) { if (request != NULL && request->cancel) - break; - else - continue; + { + gftp_disconnect (request); + return (GFTP_ERETRYABLE); + } + + continue; } if (request != NULL) @@ -2530,16 +2537,13 @@ g_strerror (errno)); gftp_disconnect (request); } + return (GFTP_ERETRYABLE); } + break; } - - if (errno == EINTR && request != NULL && request->cancel) - { - gftp_disconnect (request); - return (GFTP_ERETRYABLE); - } + while (1); return (ret); } @@ -2565,12 +2569,15 @@ tv.tv_sec = network_timeout; tv.tv_usec = 0; ret = select (fd + 1, NULL, &fset, NULL, &tv); - if (ret == -1 && errno == EINTR) + if (ret == -1 && (errno == EINTR || errno == EAGAIN)) { if (request != NULL && request->cancel) - break; - else - continue; + { + gftp_disconnect (request); + return (GFTP_ERETRYABLE); + } + + continue; } else if (ret <= 0) { @@ -2581,18 +2588,22 @@ request->hostname); gftp_disconnect (request); } + return (GFTP_ERETRYABLE); } w_ret = write (fd, 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; } if (request != NULL) @@ -2602,6 +2613,7 @@ g_strerror (errno)); gftp_disconnect (request); } + return (GFTP_ERETRYABLE); } @@ -2611,12 +2623,6 @@ } while (size > 0); - if (errno == EINTR && request != NULL && request->cancel) - { - gftp_disconnect (request); - return (GFTP_ERETRYABLE); - } - return (ret); } @@ -2823,7 +2829,7 @@ { ret1 = select (0, NULL, NULL, NULL, &tv); } - while (ret1 == -1 && errno == EINTR); + while (ret1 == -1 && (errno == EINTR || errno == EAGAIN)); } if ((ret1 = gftp_connect (tdata->fromreq)) == 0 &&