Browse Source

Replace elist.h with uthash.h for pool curls

Luke Dashjr 12 years ago
parent
commit
a3e3b9aa21
2 changed files with 10 additions and 10 deletions
  1. 8 8
      miner.c
  2. 2 2
      miner.h

+ 8 - 8
miner.c

@@ -59,6 +59,7 @@
 #include "driver-opencl.h"
 #include "driver-opencl.h"
 #include "bench_block.h"
 #include "bench_block.h"
 #include "scrypt.h"
 #include "scrypt.h"
+#include "utlist.h"
 
 
 #ifdef USE_AVALON
 #ifdef USE_AVALON
 #include "driver-avalon.h"
 #include "driver-avalon.h"
@@ -505,7 +506,6 @@ struct pool *add_pool(void)
 		quit(1, "Failed to pthread_cond_init in add_pool");
 		quit(1, "Failed to pthread_cond_init in add_pool");
 	cglock_init(&pool->data_lock);
 	cglock_init(&pool->data_lock);
 	mutex_init(&pool->stratum_lock);
 	mutex_init(&pool->stratum_lock);
-	INIT_LIST_HEAD(&pool->curlring);
 	pool->swork.transparency_time = (time_t)-1;
 	pool->swork.transparency_time = (time_t)-1;
 
 
 	/* Make sure the pool doesn't think we've been idle since time 0 */
 	/* Make sure the pool doesn't think we've been idle since time 0 */
@@ -3570,7 +3570,7 @@ static void recruit_curl(struct pool *pool)
 	if (unlikely(!ce->curl))
 	if (unlikely(!ce->curl))
 		quit(1, "Failed to init in recruit_curl");
 		quit(1, "Failed to init in recruit_curl");
 
 
-	list_add(&ce->node, &pool->curlring);
+	LL_PREPEND(pool->curllist, ce);
 	pool->curls++;
 	pool->curls++;
 }
 }
 
 
@@ -3590,7 +3590,7 @@ retry:
 	if (!pool->curls) {
 	if (!pool->curls) {
 		recruit_curl(pool);
 		recruit_curl(pool);
 		recruited = true;
 		recruited = true;
-	} else if (list_empty(&pool->curlring)) {
+	} else if (!pool->curllist) {
 		if (blocking < 2 && pool->curls >= curl_limit && (blocking || pool->curls >= opt_submit_threads)) {
 		if (blocking < 2 && pool->curls >= curl_limit && (blocking || pool->curls >= opt_submit_threads)) {
 			if (!blocking) {
 			if (!blocking) {
 				mutex_unlock(&pool->pool_lock);
 				mutex_unlock(&pool->pool_lock);
@@ -3603,8 +3603,8 @@ retry:
 			recruited = true;
 			recruited = true;
 		}
 		}
 	}
 	}
-	ce = list_entry(pool->curlring.next, struct curl_ent, node);
-	list_del(&ce->node);
+	ce = pool->curllist;
+	LL_DELETE(pool->curllist, ce);
 	mutex_unlock(&pool->pool_lock);
 	mutex_unlock(&pool->pool_lock);
 
 
 	if (recruited)
 	if (recruited)
@@ -3628,7 +3628,7 @@ static void push_curl_entry(struct curl_ent *ce, struct pool *pool)
 	mutex_lock(&pool->pool_lock);
 	mutex_lock(&pool->pool_lock);
 	if (!ce || !ce->curl)
 	if (!ce || !ce->curl)
 		quit(1, "Attempted to add NULL in push_curl_entry");
 		quit(1, "Attempted to add NULL in push_curl_entry");
-	list_add_tail(&ce->node, &pool->curlring);
+	LL_PREPEND(pool->curllist, ce);
 	cgtime(&ce->tv);
 	cgtime(&ce->tv);
 	pthread_cond_broadcast(&pool->cr_cond);
 	pthread_cond_broadcast(&pool->cr_cond);
 	mutex_unlock(&pool->pool_lock);
 	mutex_unlock(&pool->pool_lock);
@@ -7569,13 +7569,13 @@ static void reap_curl(struct pool *pool)
 	cgtime(&now);
 	cgtime(&now);
 
 
 	mutex_lock(&pool->pool_lock);
 	mutex_lock(&pool->pool_lock);
-	list_for_each_entry_safe(ent, iter, &pool->curlring, node) {
+	LL_FOREACH_SAFE(pool->curllist, ent, iter) {
 		if (pool->curls < 2)
 		if (pool->curls < 2)
 			break;
 			break;
 		if (now.tv_sec - ent->tv.tv_sec > 300) {
 		if (now.tv_sec - ent->tv.tv_sec > 300) {
 			reaped++;
 			reaped++;
 			pool->curls--;
 			pool->curls--;
-			list_del(&ent->node);
+			LL_DELETE(pool->curllist, ent);
 			curl_easy_cleanup(ent->curl);
 			curl_easy_cleanup(ent->curl);
 			free(ent);
 			free(ent);
 		}
 		}

+ 2 - 2
miner.h

@@ -1022,7 +1022,7 @@ typedef struct {
 
 
 struct curl_ent {
 struct curl_ent {
 	CURL *curl;
 	CURL *curl;
-	struct list_head node;
+	struct curl_ent *next;
 	struct timeval tv;
 	struct timeval tv;
 };
 };
 
 
@@ -1128,7 +1128,7 @@ struct pool {
 
 
 	int curls;
 	int curls;
 	pthread_cond_t cr_cond;
 	pthread_cond_t cr_cond;
-	struct list_head curlring;
+	struct curl_ent *curllist;
 	struct submit_work_state *sws_waiting_on_curl;
 	struct submit_work_state *sws_waiting_on_curl;
 
 
 	time_t last_work_time;
 	time_t last_work_time;