From 1a74bc5631fcdf4770da9e9cf36bbc178a5077a7 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 14 Mar 2013 22:08:19 +1100 Subject: [PATCH] Only curl easy cleanup a stratum curl if it exists. --- util.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/util.c b/util.c index 911d92c0..c4fb95ae 100644 --- a/util.c +++ b/util.c @@ -1508,15 +1508,17 @@ void suspend_stratum(struct pool *pool) applog(LOG_INFO, "Closing socket for stratum pool %d", pool->pool_no); mutex_lock(&pool->stratum_lock); pool->stratum_active = pool->stratum_notify = false; + if (pool->stratum_curl) { #if CURL_HAS_KEEPALIVE - curl_easy_cleanup(pool->stratum_curl); + curl_easy_cleanup(pool->stratum_curl); #else - /* Old versions of libcurl seem to crash occasionally on this since - * the socket is modified in keep_sockalive in ways curl does not - * know about so sacrifice the ram knowing we leak one curl handle - * every time we disconnect stratum. */ - CLOSESOCKET(pool->sock); + /* Old versions of libcurl seem to crash occasionally on this since + * the socket is modified in keep_sockalive in ways curl does not + * know about so sacrifice the ram knowing we leak one curl handle + * every time we disconnect stratum. */ + CLOSESOCKET(pool->sock); #endif + } pool->stratum_curl = NULL; mutex_unlock(&pool->stratum_lock); }