delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/06/27/13:09:15

X-Spam-Check-By: sourceware.org
Date: Wed, 27 Jun 2007 19:08:52 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Multithreaded accept/connect locks
Message-ID: <20070627170852.GO7379@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <368730366a00 DOT 366a00368730 AT drexel DOT edu>
Mime-Version: 1.0
In-Reply-To: <368730366a00.366a00368730@drexel.edu>
User-Agent: Mutt/1.4.2.2i
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 Jun 26 16:39, wtk25 AT drexel DOT edu 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
>  http://cygwin.com/ml/cygwin-developers/2003-02/msg00064.html
> 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
>  http://www.nntp.perl.org/group/perl.ithreads/2007/01/msg1142.html
> 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 http://cygwin.com/snapshots/, your test application will run as
expected.

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

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

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

- Raw text -


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