Browse Source

Recreate cURL for new stratum connections, and clear stratum_notify on suspending them

Cherrypicked from 66c567ab2e2901537eccaeab063ce650666751e5

Conflicts:
	util.c
Con Kolivas 13 years ago
parent
commit
6ec37ee642
1 changed files with 6 additions and 6 deletions
  1. 6 6
      util.c

+ 6 - 6
util.c

@@ -1745,11 +1745,11 @@ static bool setup_stratum_curl(struct pool *pool)
 	pool->stratum_auth = false;
 	pool->stratum_auth = false;
 	pool->stratum_notify = false;
 	pool->stratum_notify = false;
 	pool->swork.transparency_probed = false;
 	pool->swork.transparency_probed = false;
-	if (!pool->stratum_curl) {
-		pool->stratum_curl = curl_easy_init();
-		if (unlikely(!pool->stratum_curl))
-			quit(1, "Failed to curl_easy_init in initiate_stratum");
-	}
+	if (pool->stratum_curl)
+		curl_easy_cleanup(pool->stratum_curl);
+	pool->stratum_curl = curl_easy_init();
+	if (unlikely(!pool->stratum_curl))
+		quit(1, "Failed to curl_easy_init in initiate_stratum");
 	if (pool->sockbuf)
 	if (pool->sockbuf)
 		pool->sockbuf[0] = '\0';
 		pool->sockbuf[0] = '\0';
 	mutex_unlock(&pool->stratum_lock);
 	mutex_unlock(&pool->stratum_lock);
@@ -1964,7 +1964,7 @@ void suspend_stratum(struct pool *pool)
 	clear_sockbuf(pool);
 	clear_sockbuf(pool);
 	applog(LOG_INFO, "Closing socket for stratum pool %d", pool->pool_no);
 	applog(LOG_INFO, "Closing socket for stratum pool %d", pool->pool_no);
 	mutex_lock(&pool->stratum_lock);
 	mutex_lock(&pool->stratum_lock);
-	pool->stratum_active = false;
+	pool->stratum_active = pool->stratum_notify = false;
 	pool->stratum_auth = false;
 	pool->stratum_auth = false;
 	curl_easy_cleanup(pool->stratum_curl);
 	curl_easy_cleanup(pool->stratum_curl);
 	pool->stratum_curl = NULL;
 	pool->stratum_curl = NULL;