This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: listen socket / poll block


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]