diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2011-05-22 22:50:58 +0200 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2011-05-22 23:13:30 +0200 |
commit | 47c05b10018f5ec7493e4bd9f521aaa18d96f1e2 (patch) | |
tree | ed317d21931ab58671af4fedee2af05f3ff7908f /transact.c | |
parent | f3b0aa05fd1a1912d9c5fad7ebbaa7dcec31e047 (diff) | |
download | fetchmail-47c05b10018f5ec7493e4bd9f521aaa18d96f1e2.tar.gz fetchmail-47c05b10018f5ec7493e4bd9f521aaa18d96f1e2.tar.bz2 fetchmail-47c05b10018f5ec7493e4bd9f521aaa18d96f1e2.zip |
Fix socket timeout handling.
Fixes STARTTLS hangs reported by Thomas Jarosch.
Diffstat (limited to 'transact.c')
-rw-r--r-- | transact.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -487,6 +487,7 @@ int readheaders(int sock, char *sp, *tp; set_timeout(mytimeout); + SockTimeout(sock, mytimeout); if ((n = SockRead(sock, buf, sizeof(buf)-1)) == -1) { set_timeout(0); free(line); @@ -1408,6 +1409,7 @@ int readbody(int sock, struct query *ctl, flag forward, int len) while (protocol->delimited || len > 0) { set_timeout(mytimeout); + SockTimeout(sock, mytimeout); /* XXX FIXME: for undelimited protocols that ship the size, such * as IMAP, we might want to use the count of remaining characters * instead of the buffer size -- not for fetchmail 6.3.X though */ @@ -1551,6 +1553,7 @@ va_dcl va_end(ap); snprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), "\r\n"); + SockTimeout(sock, mytimeout); SockWrite(sock, buf, strlen(buf)); if (outlevel >= O_MONITOR) @@ -1571,6 +1574,7 @@ int gen_recv(int sock /** socket to which server is connected */, phase = SERVER_WAIT; set_timeout(mytimeout); + SockTimeout(sock, mytimeout); if (SockRead(sock, buf, size) == -1) { set_timeout(0); @@ -1684,6 +1688,7 @@ int gen_recv_split(int sock /** socket to which server is connected */, phase = SERVER_WAIT; set_timeout(mytimeout); + SockTimeout(sock, mytimeout); rr = SockRead(sock, buf + n, size - n); set_timeout(0); phase = oldphase; @@ -1755,6 +1760,7 @@ va_dcl va_end(ap); snprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), "\r\n"); + SockTimeout(sock, mytimeout); ok = SockWrite(sock, buf, strlen(buf)); if (ok == -1 || (size_t)ok != strlen(buf)) { /* short write, bail out */ |