diff options
Diffstat (limited to 'src/common/linux')
-rw-r--r-- | src/common/linux/http_upload.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/common/linux/http_upload.cc b/src/common/linux/http_upload.cc index fead76e9..d49f2276 100644 --- a/src/common/linux/http_upload.cc +++ b/src/common/linux/http_upload.cc @@ -70,7 +70,17 @@ bool HTTPUpload::SendRequest(const string &url, if (!CheckParameters(parameters)) return false; - void *curl_lib = dlopen("libcurl.so", RTLD_NOW); + // 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) { + dlerror(); // Clear dlerror before attempting to open libraries. + dlclose(curl_lib); + curl_lib = NULL; + } + if (!curl_lib) { + curl_lib = dlopen("libcurl.so", RTLD_NOW); + } if (!curl_lib) { if (error_description != NULL) *error_description = dlerror(); |