| Index: src/common/linux/http_upload.cc
|
| diff --git a/src/common/linux/http_upload.cc b/src/common/linux/http_upload.cc
|
| index 4492fe84542c00b87cae9019c1959da776078812..702526af753779c450fdff184e15f35595ae7a4c 100644
|
| --- a/src/common/linux/http_upload.cc
|
| +++ b/src/common/linux/http_upload.cc
|
| @@ -72,7 +72,9 @@ bool HTTPUpload::SendRequest(const string &url,
|
| // We may have been linked statically; if curl_easy_init is in the
|
| // current binary, no need to search for a dynamic version.
|
| void* curl_lib = dlopen(NULL, RTLD_NOW);
|
| - if (!curl_lib || dlsym(curl_lib, "curl_easy_init") == NULL) {
|
| + if (!CheckCurlLib(curl_lib)) {
|
| + fprintf(stderr,
|
| + "Failed to open curl lib from binary, use libcurl.so instead\n");
|
| dlerror(); // Clear dlerror before attempting to open libraries.
|
| dlclose(curl_lib);
|
| curl_lib = NULL;
|
| @@ -113,6 +115,10 @@ bool HTTPUpload::SendRequest(const string &url,
|
| *(void**) (&curl_easy_setopt) = dlsym(curl_lib, "curl_easy_setopt");
|
| (*curl_easy_setopt)(curl, CURLOPT_URL, url.c_str());
|
| (*curl_easy_setopt)(curl, CURLOPT_USERAGENT, kUserAgent);
|
| + // Support multithread by disabling timeout handling, would get SIGSEGV with
|
| + // Curl_resolv_timeout in stack trace otherwise.
|
| + // See https://curl.haxx.se/libcurl/c/threadsafe.html
|
| + (*curl_easy_setopt)(curl, CURLOPT_NOSIGNAL, 1);
|
| // Set proxy information if necessary.
|
| if (!proxy.empty())
|
| (*curl_easy_setopt)(curl, CURLOPT_PROXY, proxy.c_str());
|
| @@ -198,6 +204,13 @@ bool HTTPUpload::SendRequest(const string &url,
|
| }
|
|
|
| // static
|
| +bool HTTPUpload::CheckCurlLib(void* curl_lib) {
|
| + return curl_lib &&
|
| + dlsym(curl_lib, "curl_easy_init") &&
|
| + dlsym(curl_lib, "curl_easy_setopt");
|
| +}
|
| +
|
| +// static
|
| bool HTTPUpload::CheckParameters(const map<string, string> ¶meters) {
|
| for (map<string, string>::const_iterator pos = parameters.begin();
|
| pos != parameters.end(); ++pos) {
|
|
|