Browse Source

Bugfix: Address a couple of rare TQ leaks, and improve logging a bit

Luke Dashjr 13 years ago
parent
commit
e4f8574bd5
1 changed files with 6 additions and 3 deletions
  1. 6 3
      cgminer.c

+ 6 - 3
cgminer.c

@@ -2398,6 +2398,7 @@ static void *get_work_thread(void *userdata)
 	pool = wc->pool;
 
 	if (clone_available()) {
+		applog(LOG_DEBUG, "dec_queued from get_work_thread due to clone available\n");
 		dec_queued(pool);
 		goto out;
 	}
@@ -2437,6 +2438,7 @@ static void *get_work_thread(void *userdata)
 		applog(LOG_ERR, "Failed to tq_push work in workio_get_work");
 		kill_work();
 		free_work(ret_work);
+		dec_queued(pool);
 	}
 
 out:
@@ -2913,6 +2915,7 @@ static bool hash_push(struct work *work)
 
 	if (work->queued) {
 		work->queued = false;
+		applog(LOG_DEBUG, "dec_queued in hash_push\n");
 		dec_queued(work->pool);
 	}
 
@@ -2941,7 +2944,7 @@ static void *stage_thread(void *userdata)
 
 		test_work_current(work);
 
-		applog(LOG_DEBUG, "Pushing work to getwork queue");
+		applog(LOG_DEBUG, "Pushing work to getwork queue (queued=%c)", work->queued?'Y':'N');
 
 		if (unlikely(!hash_push(work))) {
 			applog(LOG_WARNING, "Failed to hash_push in stage_thread");
@@ -3925,8 +3928,6 @@ static bool queue_request(struct thr_info *thr, bool needed)
 	if (pool->staged + pool->queued >= maxq)
 		return true;
 
-	inc_queued(pool);
-
 	/* fill out work request message */
 	wc = calloc(1, sizeof(*wc));
 	if (unlikely(!wc)) {
@@ -3947,6 +3948,8 @@ static bool queue_request(struct thr_info *thr, bool needed)
 		return false;
 	}
 
+	inc_queued(pool);
+
 	return true;
 }