Perform global libcurl initialization

curl_easy_init() is not thread-safe unless curl_global_init() has
already been called.
It seems that SSL initialization is slow on Windows, so only do that
if the mining server has to be accessed via HTTPS.
Thanks to @martinwguy for pointing this out.
This commit is contained in:
pooler 2013-06-09 18:21:39 +02:00
parent f80163ec4c
commit 7528a95fe1

View file

@ -1244,6 +1244,7 @@ void signal_handler(int sig)
int main(int argc, char *argv[])
{
struct thr_info *thr;
long flags;
int i;
rpc_url = strdup(DEF_RPC_URL);
@ -1253,6 +1254,20 @@ int main(int argc, char *argv[])
/* parse command line */
parse_cmdline(argc, argv);
pthread_mutex_init(&applog_lock, NULL);
pthread_mutex_init(&stats_lock, NULL);
pthread_mutex_init(&g_work_lock, NULL);
pthread_mutex_init(&stratum.sock_lock, NULL);
pthread_mutex_init(&stratum.work_lock, NULL);
flags = strncmp(rpc_url, "https:", 6)
? (CURL_GLOBAL_ALL & ~CURL_GLOBAL_SSL)
: CURL_GLOBAL_ALL;
if (curl_global_init(flags)) {
applog(LOG_ERR, "CURL initialization failed");
return 1;
}
#ifndef WIN32
if (opt_background) {
i = fork();
@ -1270,12 +1285,6 @@ int main(int argc, char *argv[])
}
#endif
pthread_mutex_init(&applog_lock, NULL);
pthread_mutex_init(&stats_lock, NULL);
pthread_mutex_init(&g_work_lock, NULL);
pthread_mutex_init(&stratum.sock_lock, NULL);
pthread_mutex_init(&stratum.work_lock, NULL);
#if defined(WIN32)
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);