Support statically-linked libcurl for HTTP uploads in Linux

https://breakpad.appspot.com/1064002/



git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1277 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
mattdr.breakpad@gmail.com 2014-01-29 20:34:07 +00:00
parent c590a7f322
commit 9dd2ab720e

View File

@ -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();