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: Multithreaded accept/connect locks

On Jun 26 16:39, wrote:
> I'm trying to test some socket code inside a single process.  I have two threads, a server and a client, and try to connect a Unix domain socket between them, but the threads block on accept() and connect() respectively.  I've tried blocking on select() so that the accept() does not block, with the same results.  When the server and client are forked into different processes, the connection works fine.
> This problem seems similar to that reported in
> except that my sockets are Unix domain, so my connecting socket should be looking in the right place.
> However, that thread is pretty old, and I'm running a more recent version of Cygwin.

No, that's unrelated.

> The problem is also possibly related to
> Although I don't know any perl, so maybe not.

Yes, that's the same problem.  From stracing the problem it appears
that the underlying problem is in WinSock.  connect returns with an
error 10036, WSAEINPROGRESS, because the other thread is at that time
executing a blocking socket call (accept).  The problem is aggravated
by the fact that the connect call in Cygwin is always using non-blocking
mode and WSAEINPROGRESS is also referring to a connect which is still
in progress and needs further handling.

In CVS, the Cygwin socket code has been reworked a lot.  One important
change is that besides recv/send/connect also accept is now implemented
in non-blocking mode under the hood.  This has the effect that the
connect call should't be able to fail due to a blocking accept in
the same process.  If you try your application against a recent snapshot
from, your test application will run as

However, if you want the application to work with 1.5.24 as well, you
should consider to implement accept in non-blocking mode manually in
your application.


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

Unsubscribe info:
Problem reports:

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