Commit e8e88beff10641a9f6e578f41ff1620f2bb3a5d3

Con Kolivas 2013-02-16T12:28:50

Create a central point for removal of work items completed by queued device drivers.

diff --git a/cgminer.c b/cgminer.c
index c9f02e7..a562b3f 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -5614,6 +5614,16 @@ static void fill_queue(struct thr_info *mythr, struct cgpu_info *cgpu, struct de
 	} while (!drv->queue_full(cgpu));
 }
 
+/* This function should be used by queued device drivers when they're sure
+ * the work struct is no longer in use. */
+void work_completed(struct cgpu_info *cgpu, struct work *work)
+{
+	wr_lock(&cgpu->qlock);
+	HASH_DEL(cgpu->queued_work, work);
+	wr_unlock(&cgpu->qlock);
+	free_work(work);
+}
+
 /* This version of hash work is for devices that are fast enough to always
  * perform a full nonce range and need a queue to maintain the device busy.
  * Work creation and destruction is not done from within this function
diff --git a/miner.h b/miner.h
index 14d5338..9f7d3b5 100644
--- a/miner.h
+++ b/miner.h
@@ -1093,6 +1093,7 @@ struct modminer_fpga_state {
 
 extern void get_datestamp(char *, struct timeval *);
 extern void submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
+extern void work_completed(struct cgpu_info *cgpu, struct work *work);
 extern void tailsprintf(char *f, const char *fmt, ...);
 extern void wlogprint(const char *f, ...);
 extern int curses_int(const char *query);