Understanding CURLOPT_NOSIGNAL
We were faced with a libcurl related crash in this release.
The code making DNS requests in a kubernetes cluster crashed when left to run overnight.
Most posts suggested to use CURLOPT_NOSIGNAL set to 1 to solve the issue.
Although its pretty much clear why this issue happens (https://curl.haxx.se/libcurl/c/CURLOPT_NOSIGNAL.html), the effects of setting CURLOPT_NOSIGNAL to 1 were not yet clear to me.
After some study I found the following
If you have a multi threaded c++ application setting CURLOPT_NOSIGNAL to 1
will do the following
- libcurl will no longer install signal handlers. This means you need to install handlers for SIGPIPE and SIGCHILD yourself in your application. Otherwise you may end up in another crash.
- libcurl will not timeout when a DNS resolution takes too long. So you will need to understand which requests are timing out and kill the request if it takes too long.
The right approach I feel is to compile libcurl with c-ares support and leave the CURLOPT_NOSIGNAL to its default value .i.e. 0
This way the DNS resolution related alarms will not be trigerred and SIGPIPE related handlers will be installed by libcurl.
Comments
Post a Comment