aboutsummaryrefslogtreecommitdiff
path: root/src/common/linux/http_upload.cc
diff options
context:
space:
mode:
authorLi Yan <lyan@chromium.org>2016-03-30 13:46:21 -0700
committerLi Yan <lyan@chromium.org>2016-03-30 13:46:21 -0700
commitc77c51fae6796fbe86ecafd6136ef9503251c035 (patch)
tree14a97e8013432c3aad82d7c95c35d96c592488cc /src/common/linux/http_upload.cc
parentMake EXC_BAD_ACCESS / EXC_I386_GPFLT print nicely in the processor (diff)
downloadbreakpad-c77c51fae6796fbe86ecafd6136ef9503251c035.tar.xz
Refactor sym_upload in tools to extract code into common/linux, and minor fixes
to code calling libcurl. This change may be used to build a tool to dump and upload symbols with multi-thread. BUG= R=mmandlis@chromium.org CC=google-breakpad-dev@googlegroups.com Review URL: https://codereview.chromium.org/1842113002 .
Diffstat (limited to 'src/common/linux/http_upload.cc')
-rw-r--r--src/common/linux/http_upload.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/common/linux/http_upload.cc b/src/common/linux/http_upload.cc
index 4492fe84..702526af 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> &parameters) {
for (map<string, string>::const_iterator pos = parameters.begin();
pos != parameters.end(); ++pos) {