delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/03/23/04:06:09

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00
X-Spam-Check-By: sourceware.org
To: "Cygwin Mailing List" <cygwin AT cygwin DOT com>
Subject: Re: recvfrom + MSG_PEEK = broken?
References: <4BA7085D DOT 3050307 AT cwilson DOT fastmail DOT fm> <20100322110352 DOT GA32321 AT calimero DOT vinschen DOT de> <4BA7D40E DOT 5010504 AT etr-usa DOT com> <4BA85E92 DOT 5080700 AT cwilson DOT fastmail DOT fm>
Date: Tue, 23 Mar 2010 10:05:50 +0100
MIME-Version: 1.0
From: "Matthias Andree" <matthias DOT andree AT gmx DOT de>
Message-ID: <op.u90jj0ww1e62zd@merlin.emma.line.org>
In-Reply-To: <4BA85E92.5080700@cwilson.fastmail.fm>
User-Agent: Opera Mail/10.10 (Linux)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/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

Am 23.03.2010, 07:24 Uhr, schrieb Charles Wilson:

> On 3/22/2010 4:33 PM, Warren Young wrote:
>> On 3/22/2010 5:03 AM, Corinna Vinschen wrote:
>>> The last time I had problems with MSG_PEEK was back in 2006.  Curious
>>> how seldomly it's used, apparently.
>>
>> Peeking is evil:
>>
>>     http://tangentsoft.net/wskfaq/newbie.html#peeking
>>
>> The extra kernel context switch problem isn't Windows-specific, so
>> peeking should be avoided in all code for that reason alone.
>
> That's all well and good, but I'm not writing new code; I also see no
> need to rewrite xinetd from the ground up, as that'd be what it would
> take to avoid the use of MSG_PEEK.  I'm simply trying to get existing
> code, which uses normal POSIX functions in their normal, documented way,
> to work properly.  recvfrom has a specific, documented POSIX behavior,
> and that behavior includes MSG_PEEK.  Cygwin's implementation didn't
> work before; now it does. That's a plus, no matter what some random
> webpage might think about the function.

FWIW, fetchmail has had a Cygwin-specific workaround for a  
recvfrom(...MSG_PEEK)/read sequence for ages (since 2001, to be precise).  
Perhaps a similar workaround might want to migrate into Cygwin, unless  
it's already there (if so, I'd like to know the version so I can make this  
workaround depend on the Cygwin version).

The code was originally from Jason Tishler (see URL embedded in the  
comment) and is now upstream in socket.c, full reference:  
<http://gitorious.org/fetchmail/fetchmail/blobs/master/socket.c> ll.  
999ff. currently:

#ifdef __CYGWIN__
/*
  * Workaround Microsoft Winsock recv/WSARecv(..., MSG_PEEK) bug.
  * See http://sources.redhat.com/ml/cygwin/2001-08/msg00628.html
  * for more details.
  */
static ssize_t cygwin_read(int sock, void *buf, size_t count)
{
...

and tries to do a 2nd read to fill "count" in.

> Err...sure. "I want to design my networking stack in such a way that it
> can't support a specific POSIX call, so I'll blame POSIX"

Rumors have it that WinSock was derived from a BSD stack, and relevant  
TCP/IP fingerprints supported that. I never bothered to check though.

-- 
Matthias Andree

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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