delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/04/29/07:57:42

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
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 <jason AT tishler DOT net>
Subject: Cygwin Winsock recv/WSARecv(..., MSG_PEEK) patch
To: fetchmail-friends AT lists DOT ccil DOT org
Cc: Cygwin <cygwin AT cygwin DOT com>
Mail-followup-to: fetchmail-friends AT lists DOT ccil DOT org, Cygwin <cygwin AT cygwin DOT com>
Message-id: <20020429120347.GA1152@tishler.net>
MIME-version: 1.0
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)--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019