Browse Source

Bugfix: Shutdown stratum socket when initiate fails, so it doesn't linger

Luke Dashjr 13 years ago
parent
commit
5d1d433453
1 changed files with 7 additions and 0 deletions
  1. 7 0
      util.c

+ 7 - 0
util.c

@@ -1355,6 +1355,7 @@ bool initiate_stratum(struct pool *pool)
 		curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
 	}
 	curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1);
+	pool->sock = INVSOCK;
 	if (curl_easy_perform(curl)) {
 		applog(LOG_INFO, "Stratum connect failed to pool %d: %s", pool->pool_no, curl_err_str);
 		goto out;
@@ -1430,7 +1431,13 @@ out:
 			       pool->pool_no, pool->nonce1, pool->n2size);
 		}
 	} else
+	{
 		applog(LOG_DEBUG, "Initiate stratum failed");
+		if (pool->sock != INVSOCK) {
+			shutdown(pool->sock, SHUT_RDWR);
+			pool->sock = INVSOCK;
+		}
+	}
 
 	return ret;
 }