There is no need for the submit and getwork curls to be tied to the pool struct.
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
diff --git a/cgminer.c b/cgminer.c
index dba807a..ad8ad96 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -1965,6 +1965,7 @@ static void *get_work_thread(void *userdata)
{
struct pool *pool = (struct pool *)userdata;
struct workio_cmd *wc;
+ CURL *curl;
pthread_detach(pthread_self());
@@ -1973,9 +1974,8 @@ static void *get_work_thread(void *userdata)
if (!pool->getwork_q)
quit(1, "Failed to tq_new in get_work_thread");
- /* getwork_curl never cleared */
- pool->getwork_curl = curl_easy_init();
- if (unlikely(!pool->getwork_curl))
+ curl = curl_easy_init();
+ if (unlikely(!curl))
quit(1, "Failed to initialise pool getwork CURL");
while ((wc = tq_pop(pool->getwork_q, NULL)) != NULL) {
@@ -1992,7 +1992,7 @@ static void *get_work_thread(void *userdata)
ret_work->pool = pool;
/* obtain new work from bitcoin via JSON-RPC */
- while (!get_upstream_work(ret_work, pool->getwork_curl)) {
+ while (!get_upstream_work(ret_work, curl)) {
if (unlikely((opt_retries >= 0) && (++failures > opt_retries))) {
applog(LOG_ERR, "json_rpc_call failed, terminating workio thread");
free_work(ret_work);
@@ -2019,6 +2019,7 @@ static void *get_work_thread(void *userdata)
workio_cmd_free(wc);
}
+ curl_easy_cleanup(curl);
return NULL;
}
@@ -2121,6 +2122,7 @@ static void *submit_work_thread(void *userdata)
{
struct pool *pool = (struct pool *)userdata;
struct workio_cmd *wc;
+ CURL *curl;
pthread_detach(pthread_self());
@@ -2129,9 +2131,8 @@ static void *submit_work_thread(void *userdata)
if (!pool->submit_q )
quit(1, "Failed to tq_new in submit_work_thread");
- /* submit_curl never cleared */
- pool->submit_curl = curl_easy_init();
- if (unlikely(!pool->submit_curl))
+ curl = curl_easy_init();
+ if (unlikely(!curl))
quit(1, "Failed to initialise pool submit CURL");
while ((wc = tq_pop(pool->submit_q, NULL)) != NULL) {
@@ -2157,7 +2158,7 @@ static void *submit_work_thread(void *userdata)
}
/* submit solution to bitcoin via JSON-RPC */
- while (!submit_upstream_work(work, pool->submit_curl)) {
+ while (!submit_upstream_work(work, curl)) {
if (stale_work(work, true)) {
applog(LOG_NOTICE, "Share became stale while retrying submit, discarding");
total_stale++;
@@ -2180,6 +2181,7 @@ static void *submit_work_thread(void *userdata)
workio_cmd_free(wc);
}
+ curl_easy_cleanup(curl);
return NULL;
}
diff --git a/miner.h b/miner.h
index 2d23804..6c750be 100644
--- a/miner.h
+++ b/miner.h
@@ -634,9 +634,6 @@ struct pool {
pthread_t longpoll_thread;
pthread_t submit_thread;
pthread_t getwork_thread;
-
- CURL *submit_curl;
- CURL *getwork_curl;
};
struct work {