curl / Mailing Lists / curl-library / Single Mail

curl-library

curl_easy_perform blocks when ifdown the ntwk interface

From: Matthews, Jeremy via curl-library <curl-library_at_cool.haxx.se>
Date: Fri, 9 Nov 2018 16:40:44 +0000

Hi,

I have some C++ code which sends REST requests periodically. Here are some options that are set and then the curl_easy_perform call (a HEAD message is being sent):

    curl_easy_setopt(mhCurl, CURLOPT_HTTPHEADER, chunk);
    curl_easy_setopt(mhCurl, CURLOPT_URL, f_szUrl.c_str());
    curl_easy_setopt(mhCurl, CURLOPT_CONNECTTIMEOUT, f_lTimeoutSec);
    curl_easy_setopt(mhCurl, CURLOPT_CUSTOMREQUEST, NULL);
    curl_easy_setopt(mhCurl, CURLOPT_NOBODY, 1L);
    curl_easy_setopt(mhCurl, CURLOPT_POST, 0L);
    curl_easy_setopt(mhCurl, CURLOPT_UPLOAD, 0L);
    curl_easy_setopt(mhCurl, CURLOPT_HEADERDATA, (void *)&rsp);
    ret = curl_easy_perform(mhCurl);

This is in executable running in Linux. At the Linux command line, if I do an ifdown on the network interface upon which the message is sent, then curl_easy_perform blocks and does not return.

The CURLOPT_CONNECTTIMEOUT value is 3 seconds, but that doesn't appear to be having an effect.

How do I get curl_easy_perform to return if the network interface is down? Is there an option to do this?

I noticed that there is a curl_multi_perform that doesn't block, but I'm hoping to not go that route, because that would require a different handle type that is used in multiple places in the code.

Should the interface somehow be checked before calling curl_easy_perform?

Thanks in advance for any thoughts!

Jeremy

-----------------------------------------------------------------------------------------------------------------------
Notice: This e-mail together with any attachments may contain information of Ribbon Communications Inc. that
is confidential and/or proprietary for the sole use of the intended recipient. Any review, disclosure, reliance or
distribution by others or forwarding without express permission is strictly prohibited. If you are not the intended
recipient, please notify the sender immediately and then delete all copies, including any attachments.
-----------------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2018-11-09