Don't reuse any curl handles for solo mining and break out of the lp thread if the pool is removed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
diff --git a/cgminer.c b/cgminer.c
index 1f347bc..7a32bb2 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -6890,15 +6890,15 @@ static void gen_solo_work(struct pool *pool, struct work *work);
static void update_gbt_solo(struct pool *pool)
{
struct work *work = make_work();
- struct curl_ent *ce;
int rolltime;
json_t *val;
+ CURL *curl;
- ce = pop_curl_entry(pool);
+ curl = curl_easy_init();
/* Bitcoind doesn't like many open RPC connections. */
- curl_easy_setopt(ce->curl, CURLOPT_FORBID_REUSE, 1);
+ curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1);
retry:
- val = json_rpc_call(ce->curl, pool->rpc_url, pool->rpc_userpass, pool->rpc_req,
+ val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, pool->rpc_req,
true, false, &rolltime, pool, false);
if (likely(val)) {
@@ -6921,7 +6921,7 @@ retry:
goto retry;
}
out:
- push_curl_entry(ce, pool);
+ curl_easy_cleanup(curl);
}
static void gen_solo_work(struct pool *pool, struct work *work)
@@ -7896,13 +7896,17 @@ retry_pool:
if (pool->gbt_solo) {
applog(LOG_WARNING, "Block change for %s detection via getblockcount polling",
cp->rpc_url);
+ /* Bitcoind doesn't like many open RPC connections. */
+ curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1);
while (42) {
json_t *val, *res_val = NULL;
+ if (unlikely(pool->removed))
+ goto out;
+
cgtime(&start);
wait_lpcurrent(cp);
sprintf(lpreq, "{\"id\": 0, \"method\": \"getblockcount\"}\n");
- curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 0);
val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, lpreq, true,
false, &rolltime, pool, false);
if (likely(val))
@@ -7919,12 +7923,6 @@ retry_pool:
update_gbt_solo(pool);
continue;
}
- sprintf(lpreq, "{\"id\": 0, \"method\": \"getblockhash\", \"params\": [%d]}\n", height);
- /* Reuse the connection only once for the hash
- * query since it's done immediately after the
- * height query and then drop it since bitcoind
- * doesn't like many open connections. */
- curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1);
val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass,
lpreq, true, false, &rolltime, pool, false);
if (val) {