cURL / Mailing Lists / curl-library / Single Mail

curl-library

FW: Re: successful multi-threaded use of libcurl

From: Brad Smith <brad_at_e-critical.com>
Date: Mon, 8 Oct 2001 14:13:53 -0700

Just learned that gethostbyname_r() function is reentrant and therefore
thread safe, whereas gethostbyname() is not thread safe so I shouldn't be
using it.

I'll be looking into this further.
Sorry for the confusion
brad

-----Original Message-----
From: Brad Smith [mailto:brad_at_e-critical.com]
Sent: Monday, October 08, 2001 12:24 PM
To: curl-library_at_lists.sourceforge.net
Subject: Re: successful multi-threaded use of libcurl

Thought I'd pass along my multi-threaded experience using libcurl:

I'm using libcurl 7.8 on Red Hat Linux 6.2. I'm writing a multi-threaded
app to download urls. On my first pass, I wrote it single-threaded and
everything worked fine. Then I changed the app to do downloads in multiple
threads and I would randomly (about 1 out of 10 runs) get an immediate hard
exit from my program. After further investigation, I found the program was
exiting in the gethostbyname_r call. "./configure" found the correct
gethostbyname_r function with 6 arguments. So I removed the
HAVE_GETHOSTBYNAME_R_6 and HAVE_GETHOSTNAME_R #defines in config.h so that
the gethostbyname function would get called instead of gethostbyname_r in
hostip.c and everything seems to work fine.

I'm guessing there's a problem with a static variable or something in the
gethostname_r function, but I haven't looked at the C runtime library
source. I went to the Red Hat website and saw no mention of any problems
with the function.

Hope this helps
Keep up the good work
brad
Received on 2001-10-08