curl-library
RE: curl_easy_perform blocks when ifdown the ntwk interface
Date: Tue, 13 Nov 2018 17:41:55 +0000
Thank you for your input.
Well, curl_easy_perform did appear to block. When the interface was down, the function did not return, let alone return an error code.
I have made this change:
< curl_easy_setopt(mhCurl, CURLOPT_CONNECTTIMEOUT, f_lTimeoutSec);
---
> curl_easy_setopt(mhCurl, CURLOPT_TIMEOUT, f_lTimeoutSec);
...and curl_easy_perform now returns and with the expected return code of 45 (CURLE_INTERFACE_FAILED).
Could there be an issue here with curl_easy_perform (and the earlier option) if the interface is down?
I usually do not fiddle with ifdown and ifup. I was just trying to simulate a network issue.
Thanks,
Jeremy
From: curl-library <curl-library-bounces_at_cool.haxx.se> On Behalf Of curl-library-request_at_cool.haxx.se
Sent: Tuesday, November 13, 2018 5:00 AM
To: curl-library_at_cool.haxx.se
Subject: curl-library Digest, Vol 159, Issue 11
________________________________
NOTICE: This email was received from an EXTERNAL sender
________________________________
Send curl-library mailing list submissions to
curl-library_at_cool.haxx.se<mailto:curl-library_at_cool.haxx.se>
To subscribe or unsubscribe via the World Wide Web, visit
https://cool.haxx.se/cgi-bin/mailman/listinfo/curl-library<https://cool.haxx.se/cgi-bin/mailman/listinfo/curl-library>
or, via email, send a message with subject or body 'help' to
curl-library-request_at_cool.haxx.se<mailto:curl-library-request_at_cool.haxx.se>
You can reach the person managing the list at
curl-library-owner_at_cool.haxx.se<mailto:curl-library-owner_at_cool.haxx.se>
When replying, please edit your Subject line so it is more specific
than "Re: Contents of curl-library digest..."
Today's Topics:
1. Re: curl_easy_perform blocks when ifdown the ntwk interface
(doa379)
----------------------------------------------------------------------
Message: 1
Date: Mon, 12 Nov 2018 13:03:23 +0000
From: doa379 <doa379_at_gmail.com<mailto:doa379_at_gmail.com>>
To: curl-library_at_cool.haxx.se<mailto:curl-library_at_cool.haxx.se>
Subject: Re: curl_easy_perform blocks when ifdown the ntwk interface
Message-ID: <8db8f502-c31f-9871-a153-27934a5c19f9_at_gmail.com<mailto:8db8f502-c31f-9871-a153-27934a5c19f9_at_gmail.com>>
Content-Type: text/plain; charset=utf-8; format=flowed
> 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?
>
If the network is down, curl_easy_perform sends a return code. These are
the timeout settings I regularly use:
const long dl_lowspeed_bytes = 1000; /* 1K */
const long dl_lowspeed_time = 10; /* sec */
/* bytes/sec */
curl_easy_setopt(<easy_handle>, CURLOPT_LOW_SPEED_LIMIT, dl_lowspeed_bytes);
/* seconds while below low speed limit before aborting */
curl_easy_setopt(<easy_handle>, CURLOPT_LOW_SPEED_TIME, dl_lowspeed_time);
There is no reason to fiddle with the Debian tools ifdown or ifup. Info:
ifdown only works on the network interface and not the network connection.
Second, the curl multi handle is useful if you're doing a batch transfer
(many connections in one go). You can still use it but it's not
necessary for simple or one off transfers, or unless in scenarios where
you have to care about rate limitation.
------------------------------
Subject: Digest Footer
_______________________________________________
curl-library mailing list
curl-library_at_cool.haxx.se<mailto:curl-library_at_cool.haxx.se>
https://cool.haxx.se/cgi-bin/mailman/listinfo/curl-library<https://cool.haxx.se/cgi-bin/mailman/listinfo/curl-library>
------------------------------
End of curl-library Digest, Vol 159, Issue 11
*********************************************
-----------------------------------------------------------------------------------------------------------------------
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-13