Commit 195ea6358901d9bfd4f85ecd5d70fffea926a7ca

Con Kolivas 2013-03-14T22:05:42

Sacrifice the ram of curl handles in stratum disconnects when we have built with old libcurl to avoid crashes.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/util.c b/util.c
index 1c77df1..911d92c 100644
--- a/util.c
+++ b/util.c
@@ -1508,7 +1508,15 @@ 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 CURL_HAS_KEEPALIVE
 	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);
+#endif
 	pool->stratum_curl = NULL;
 	mutex_unlock(&pool->stratum_lock);
 }