cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: cannot connect to server in a subthread

From: Patrick Monnerat <Patrick.Monnerat_at_datasphere.ch>
Date: Tue, 14 Oct 2008 15:50:41 +0200

 
Michael Helmich wrote:
> I recompiled libcurl with -DNEED_REENTRANT, not my application. After
getting the hint about REENTRANT from Patrick, I searched the curl
sources for this text and found some #ifdefs around variables called
NEED_REENTRANT and _REENTRANT. So I did a rebuild of libcurl with CFLAGS
set to -DNEED_REENTRANT. Afterwards my application worked fine (i.e. it
got a connection in a subthread) without recompiling it, at least not
with the option -DNEED_REENTRANT.

Thank you for the info, Michael.

I do not have a Solaris to test now, but I have looked to the
m4/curl-reentrant.m4 file: It currently checks if _REENTRANT is not
predefined but needed to force definition of some *_r() functions.
_REENTRANT is explicitly defined only in this case.

I can imagine the initial Michael's Solaris build did not need
_REENTRANT to define the *_r() functions, thus preventing _REENTRANT
explicit definition: this is a libcurl configuration bug.

If I remember well the problem I had long ago (in a proprietary project
called "cofi"), it was related to errno. So it is not sufficient to
check for *_r() functions. IMHO, an additional check for errno behaviour
would not be satisfactory, because we don't know for sure if _REENTRANT
has some other hidden impact or not. Even in the case we check in each
system's include file, we cannot guarantee Sun will not change this is
some future release.

In the cofi's configure file, I solved to problem by defining _REENTRANT
inconditionally. I think the half way between cofi and the current
libcurl situation would be appropriate: Whatever the system is, check if
_REENTRANT is already defined; if not, define it, even if not really
needed.

We can even suppress autoconf macro for it if we code the above
statement in C like:

#ifndef _REENTRANT
# define _REENTRANT 1
#endif

Yang, I presume this is a job for you, if you wouldn't mind.
Received on 2008-10-14