cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Connection check problems on windows with multi thread.

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 17 Feb 2002 12:34:23 +0100 (MET)

On Thu, 14 Feb 2002, chicco wrote:

> Few days ago I've asked for help because my multithreads application seems
> to stuck when working with more than 10 threads on windows.
>
> It seems that the problem is the recheck that is done in curl for a
> connection after it is established.
>
> After curl establish new connection (connect() in connect.c) it calls
> socketerror() even though the return code from connect() is - 0 which mean
> that the connection established. socketerror() is calling getsockopt() and
> it seems that in windows with a lot of threads working simultaneously this
> cause the problem. Because there is no need to recheck the connection (as
> it seems to me), I don't perform the recheck and the application is working
> properly.
>
> Is this a bug or did I missed something ?

As an addition to Bjorn Reese's three different scenarios that can happen, I
must add the forth:

Several TCP/IP stacks return 0 on the connect() call for non-blocking
connects, even though it isn't connected "for real". Only by checking the
socketerror() we learn if the connect was truly successful or not.

The question here is: why does this fail on windows during these
circumstances when it seems to work most of the time?

I can think of one (somewhat ugly) work-around for this, and that is to not
do the socketerror() check on windows systems.

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2002-02-17