aboutsummaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2002-05-24 07:28:44 +0000
committerEric S. Raymond <esr@thyrsus.com>2002-05-24 07:28:44 +0000
commit68172295d4d04c206f01fc4865dd5c41f84726dd (patch)
tree0c3e74814d7e15a0ade8b1fd8cec24755336a9c4 /socket.c
parentb125c5066a96955b35e8d5419f5820c0459f28aa (diff)
downloadfetchmail-68172295d4d04c206f01fc4865dd5c41f84726dd.tar.gz
fetchmail-68172295d4d04c206f01fc4865dd5c41f84726dd.tar.bz2
fetchmail-68172295d4d04c206f01fc4865dd5c41f84726dd.zip
Cygwin port patch.
svn path=/trunk/; revision=3617
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/socket.c b/socket.c
index 3310b179..2d356ece 100644
--- a/socket.c
+++ b/socket.c
@@ -536,7 +536,7 @@ int SockWrite(int sock, char *buf, int len)
int SockRead(int sock, char *buf, int len)
{
char *newline, *bp = buf;
- int n;
+ int n, n2;
#ifdef SSL_ENABLE
SSL *ssl;
#endif
@@ -627,8 +627,25 @@ int SockRead(int sock, char *buf, int len)
if ((newline = memchr(bp, '\n', n)) != NULL)
n = newline - bp + 1;
#ifndef __BEOS__
- if ((n = fm_read(sock, bp, n)) == -1)
+ if ((n2 = fm_read(sock, bp, n)) == -1)
return(-1);
+#ifdef __CYGWIN__
+ /*
+ * Workaround Microsoft Winsock recv/WSARecv(..., MSG_PEEK) bug.
+ * See http://sources.redhat.com/ml/cygwin/2001-08/msg00628.html
+ * for more details.
+ */
+ if (n2 != n) {
+ int n3;
+ if (outlevel >= O_VERBOSE)
+ report(stdout, GT_("Cygwin socket read retry\n"));
+ n3 = fm_read(sock, bp + n2, n - n2);
+ if (n3 == -1 || n2 + n3 != n) {
+ report(stderr, GT_("Cygwin socket read retry failed!\n"));
+ return(-1);
+ }
+ }
+#endif /* __CYGWIN__ */
#endif /* __BEOS__ */
#endif
bp += n;