Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Mon, 29 Apr 2002 08:03:47 -0400 From: Jason Tishler Subject: Cygwin Winsock recv/WSARecv(..., MSG_PEEK) patch To: fetchmail-friends AT lists DOT ccil DOT org Cc: Cygwin Mail-followup-to: fetchmail-friends AT lists DOT ccil DOT org, Cygwin Message-id: <20020429120347.GA1152@tishler.net> MIME-version: 1.0 Content-type: multipart/mixed; boundary="Boundary_(ID_KKQrmcGTH2hZEQ9w70dNnQ)" User-Agent: Mutt/1.3.24i --Boundary_(ID_KKQrmcGTH2hZEQ9w70dNnQ) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Content-disposition: inline Eric, Attached is a patch (against fetchmail 5.9.11) that works around the Microsoft Winsock recv/WSARecv(..., MSG_PEEK) problem that I originally post to fetchmail-friends in: http://lists.ccil.org/pipermail/fetchmail-friends/2001-August/000906.html This patch is essentially the same as the one that I posted in: http://www.cygwin.com/ml/cygwin/2001-08/msg00628.html but cleaned up as follows: o Cygwin specific code is guarded by conditional compilation o log messages use report() instead of printf() o log messages respect the --silent/--verbose options Would you consider accepting this patch into fetchmail CVS? Note the following: o Unfortunately, this problem cannot be fixed or worked around in the Cygwin DLL itself. o I have tested this patch under Red Hat Linux 7.1 without any ill effects. o I intend to become the Cygwin fetchmail (and procmail) maintainer and will be contributing pre-built fetchmail (and procmail) tarballs to the standard Cygwin distribution. BTW, please CC me since I am not subscribed to the fetchmail-friends list. Thanks, Jason --Boundary_(ID_KKQrmcGTH2hZEQ9w70dNnQ) Content-type: text/plain; charset=us-ascii; NAME=fetchmail.patch Content-transfer-encoding: 7BIT Content-disposition: attachment; filename=fetchmail.patch --- socket.c.orig Mon Apr 1 03:16:35 2002 +++ socket.c Fri Apr 26 15:45:55 2002 @@ -536,7 +536,7 @@ int SockWrite(int sock, char *buf, int l 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 le 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; --Boundary_(ID_KKQrmcGTH2hZEQ9w70dNnQ) Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ --Boundary_(ID_KKQrmcGTH2hZEQ9w70dNnQ)--