mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-28 13:00:45 +00:00
Fix segfault in ccurl_thread.cc
curl_global_init() is not thread-safe, it must be called at the start of main()
This commit is contained in:
parent
0d9052b83b
commit
77d4a55dcc
@ -105,7 +105,6 @@ void ccurl_fetch_data(thread_handle &handle, const ccurl_location_ptr &curloc)
|
|||||||
chunk.memory = NULL;
|
chunk.memory = NULL;
|
||||||
chunk.size = 0;
|
chunk.size = 0;
|
||||||
|
|
||||||
if (curl_global_init(CURL_GLOBAL_ALL) == 0) {
|
|
||||||
curl = curl_easy_init();
|
curl = curl_easy_init();
|
||||||
if (curl) {
|
if (curl) {
|
||||||
DBGP("reading curl data from '%s'", curloc->uri);
|
DBGP("reading curl data from '%s'", curloc->uri);
|
||||||
@ -132,8 +131,6 @@ void ccurl_fetch_data(thread_handle &handle, const ccurl_location_ptr &curloc)
|
|||||||
|
|
||||||
curl_easy_cleanup(curl);
|
curl_easy_cleanup(curl);
|
||||||
}
|
}
|
||||||
curl_global_cleanup();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ccurl_thread(thread_handle &handle, const ccurl_location_ptr &curloc);
|
void ccurl_thread(thread_handle &handle, const ccurl_location_ptr &curloc);
|
||||||
|
12
src/conky.cc
12
src/conky.cc
@ -77,6 +77,9 @@
|
|||||||
#if defined BUILD_WEATHER_XOAP || defined BUILD_RSS
|
#if defined BUILD_WEATHER_XOAP || defined BUILD_RSS
|
||||||
#include <libxml/parser.h>
|
#include <libxml/parser.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef BUILD_CURL
|
||||||
|
#include <curl/curl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* local headers */
|
/* local headers */
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
@ -4401,6 +4404,11 @@ int main(int argc, char **argv)
|
|||||||
tcp_portmon_set_max_connections(0);
|
tcp_portmon_set_max_connections(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef BUILD_CURL
|
||||||
|
if(curl_global_init(CURL_GLOBAL_ALL))
|
||||||
|
NORM_ERR("curl_global_init() failed, you may not be able to use curl variables");
|
||||||
|
#endif
|
||||||
|
|
||||||
/* handle command line parameters that don't change configs */
|
/* handle command line parameters that don't change configs */
|
||||||
#ifdef BUILD_X11
|
#ifdef BUILD_X11
|
||||||
if(isutf8("LC_ALL") || isutf8("LC_CTYPE") || isutf8("LANG")) {
|
if(isutf8("LC_ALL") || isutf8("LC_CTYPE") || isutf8("LANG")) {
|
||||||
@ -4480,6 +4488,10 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
main_loop();
|
main_loop();
|
||||||
|
|
||||||
|
#ifdef BUILD_CURL
|
||||||
|
curl_global_cleanup();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
kvm_close(kd);
|
kvm_close(kd);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user