From 56068d6839f399269d3a35eee9603dba547c35e3 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 9 Mar 2013 10:30:58 +1100 Subject: [PATCH] Close any open sockets when reusing a curl handle and reopen the socket whenever we're retrying stratum. --- util.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/util.c b/util.c index fd0e6733..7ae378a3 100644 --- a/util.c +++ b/util.c @@ -1428,7 +1428,8 @@ static bool setup_stratum_curl(struct pool *pool) pool->stratum_curl = curl_easy_init(); if (unlikely(!pool->stratum_curl)) quit(1, "Failed to curl_easy_init in initiate_stratum"); - } + } else + CLOSESOCKET(pool->sock); mutex_unlock(&pool->stratum_lock); curl = pool->stratum_curl; @@ -1520,11 +1521,12 @@ bool initiate_stratum(struct pool *pool) json_error_t err; int n2size; +resend: if (!setup_stratum_curl(pool)) goto out; sockd = true; -resend: + if (recvd) { /* Get rid of any crap lying around if we're resending */ clear_sock(pool);