cURL / Mailing Lists / curl-users / Single Mail

curl-users

Putting a Curl handler into thread-local storage, doesn't seem to work for me

From: Fiona Sisk <fionasisk_at_yahoo.ie>
Date: Fri, 30 Nov 2012 15:20:20 +0000 (GMT)

hi folks, I had trouble with a C multi-threaded application with CURL calls, when the curl performs overlapped. (The problem was that I got back a response buffer was of zero length.) Eventually, I noticed that the pointer, threadCurlHandle was the same in every thread, which definitely was not what I wanted. I believed by using thread-local storage, threadCurlHandle, the pointer would be different for each Thread. Has anyone tried TLS with CURL before? Did you get it to work for you? Unfortunately I have to use globals because of the existing structure of the program. thanks Fiona /* "globals" */ /* Reuse CURL handle in thread only*/ static __thread CURL *threadCurlHandle; RunInThread {  CCORE_Debug("Starting new thread...\n");   /*  reuse CURL handle in the thread */   if((threadCurlHandle = curl_easy_init()) == NULL )

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-11-30