cURL / Mailing Lists / curl-library / Single Mail


RE: Easy handles & threads

From: Michael Mastroianni <>
Date: Wed, 28 Jul 2004 12:21:31 -0400

I am currently using curl with a lot of threads (> 300). I initially had
a lot of problems with crashes, but the problem turned out to be in the
dns lookup, which is the asynchronous version by default in the
devstudio project you get when you download the curl stuff off of source

I switched to using ares, and have had no threading problems since.

-----Original Message-----
[] On Behalf Of
Sent: Wednesday, July 28, 2004 12:05 PM
Subject: Easy handles & threads


I have to debug some libcurl code in C++ on WinXP using Visual C++ 6 and
libcurl 7.12.0 (debug-ssl and release-ssl configuration).

The code is multithreaded, and a few threads use libcurl concurrently.
Crashes occuring under heavy networking in random locations in libcurl
and in different threads lead me to the conclusion that the library is
used in an incorrect way concerning multithreading. I've read the
following statement on the website:

> libcurl is designed and implemented entirely thread safe. There are
> considerations to keep in mind when using libcurl in multiple threads
> though, as mentioned below:
> Never share easy handles between multiple threads. You should only use
> one easy handle in one single thread at any given time. You can still
> share certain data between multiple threads by using the share
> interface.

so, I went and had a look at the instantiation of the handles.
the code is basically

m_curlHandle = curl_easy_init();

so I added the following debugging output:

"Got easy handle %X for thread %X", m_curlHandle, GetCurrentThreadId()

which printed out the following list:

Got easy handle 1C23530 for thread 1E4
Got easy handle 1C2BD40 for thread 680 *
Got easy handle 1C20018 for thread 5E0
Got easy handle 1C2BD40 for thread 5E0 *
Got easy handle 1C76030 for thread F40
Got easy handle 1CA3040 for thread CAC
Got easy handle 2C1E070 for thread 5E0
Got easy handle 2C1DE90 for thread A6C
Got easy handle 2C39028 for thread D30
Got easy handle 2C73BF8 for thread CC8

So, what I see is that the same handles are given out two times
for different threads. This seems like a contradiction to the above
statement of not sharing easy handles among different threads.

Does anyone have a clue why the handles are the same for different

Received on 2004-07-28