cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_easy_perform gives CURLE_COULDNT_RESOLVE_HOST error in multi thread environment

From: Praveen Pvs <meetpraveenpvs_at_gmail.com>
Date: Sun, 30 Nov 2014 16:59:44 +0530

On Sat, Nov 29, 2014 at 2:07 PM, Dan Fandrich <dan_at_coneharvesters.com>
wrote:
Well, if you only do some of those thing, then you'll have to expect that
your
program will only fail "some" of the time. In particular, I don't see any
code
to set OpenSSL locking callbacks, nor do I see a call to curl_global_init().
Perhaps there's more. Please read those entire sections again.

>>> I have made the call curl_global_init() in my application but forgot to
put it in the sample code which i attached.
 I came across the http://curl.haxx.se/libcurl/c/threaded-ssl.html sample
multi-threaded application which uses
the SSL locking.
I have modified this application to suit my needs. Please find the attached
one (modified application)
I am creating two threads one thread will check the connection (will call
waitForHostConnection function) and other
thread will post the data (will call postDataToUrl).

Please see results of this application in different scenarios:

Starting of the application : Both the functions
return(waitForHostConnection and postDataToUrl) successful values

Pull the Ethernet cable: postDataToUrl returns 7 on curl_easy_perform and
waitForHostConnection returns 6 on curl_easy_perform

Connect the Ethernet cable back: postDataToUrl function is successful and
waitForHostConnection continues to give 6 on curl_easy_perform

I thought some problem with my waitForHostConnection function, i have
modified my application so that both threads call postDataToUrl function.
Please see the results of this modified application in different scenarios:

Starting of the application : Both the threads(both are calling
postDataToUrl) return successful values

Pull the Ethernet cable: Both the threads returns 6 on curl_easy_perform

Connect the Ethernet cable back: One thread will always be successful,
other thread will be successful sometimes (returns 6 for failure cases)

>
The problem arises when i pull the ethernet cable and connect it back.

I have set CURLOPT_NOSIGNAL to 1 for both handlers and set the SSL locking
callback.

Am I missing something here?? In my application both threads running
simultaneously and posting data parallely are must. I made sure that both
threads are having different curl handlers.

Could you please let me know where I am going wrong. Your help is greatly
appreciated.

Thank you for for your help and time.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

Received on 2014-11-30