delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/04/18/08:03:38

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Mon, 18 Apr 2011 14:01:59 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: listen socket / poll block
Message-ID: <20110418120159.GF25815@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <BANLkTim4WfCJ3w5VuDY4-Ppax5iAZZ3uCQ AT mail DOT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <BANLkTim4WfCJ3w5VuDY4-Ppax5iAZZ3uCQ@mail.gmail.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
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

On Apr  6 18:19, Thomas Stalder wrote:
> Hello,
> 
> I made a small application that block poll function.
> 
> the result is :
> 
> before pthread_create
> after pthread_create
> before poll
> before shutdown socket
> after shutdown socket
> before close socket
> after close socket
> 
> 
> under linux the result is:
> 
> before pthread_create
> after pthread_create
> before poll
> before shutdown socket
> after shutdown socket
> after poll ret=1
> error accept failed: Invalid argument

First of all, thanks for the testcase.

It turns out that the semantics of Winsock's shutdown function are
different from the Linux implementation.  Not overly surprising, but it
makes trying to get the behaviour working the same way as on Linux
a bit awkward.

The problem is that in your scenario the shutdown function works fine on
Linux, and the subsequent call to accept fails because the socket has
been shutdown for reading.  On Winsock, the shutdown function *fails*,
the error code is "socket not connected".  Thus, even if Cygwin fakes
the results for shutdown to trigger the poll call, the accept call does
*not* fail.

I applied a fix which enforces the Linux behaviour.  Please give the
next developer snapshot from http://cygwin.com/snapshots/ a try.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
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