cURL / Mailing Lists / curl-library / Single Mail


Easy handles & threads

From: <>
Date: Wed, 28 Jul 2004 09:04:34 -0700


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 some
> 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