cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Libcurl with non-reentrant gethostbyname - thread safe?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 6 Dec 2010 19:09:13 +0100 (CET)

On Mon, 6 Dec 2010, Vladimir Grishchenko wrote:

> Libcurl noob here. I'm wondering if it is safe to call libcurl from multiple
> threads if I were to use the non-reentrant variant of gethostbyname.

If libcurl is built to use a non-reentrant variant of gethostbyname, then it
isn't really thread-safe I guess.

Are you seriously using a system that doesn't have a thread-safe version of
that function? Just about evertything made during the last 15 years has this
done right...

> I looked around and didn't see any guards preventing multiple threads from
> simultaneously entering gethostbyname in libcurl. I'm planning to use
> synchronous resolver, at least initially, if that matters.

Well, using c-ares for resolving would of course be a way to avoid having to
use your system's defective gethostbyname implementation... ;-)

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2010-12-06