Commit 0316592b953647dbfa8be48dffcc955651384edd

Con Kolivas 2013-05-27T17:48:54

Spawn the avalon read thread first with info->reset set to discard any data till work is adequately queued.

diff --git a/driver-avalon.c b/driver-avalon.c
index a90dca7..6fc311c 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -877,16 +877,19 @@ static bool avalon_prepare(struct thr_info *thr)
 	if (unlikely(pthread_cond_init(&info->qcond, NULL)))
 		quit(1, "Failed to pthread_cond_init avalon qcond");
 
+	info->reset = true;
+
+	if (pthread_create(&info->read_thr, NULL, avalon_get_results, (void *)avalon))
+		quit(1, "Failed to create avalon read_thr");
+
 	if (pthread_create(&info->write_thr, NULL, avalon_send_tasks, (void *)avalon))
 		quit(1, "Failed to create avalon write_thr");
 
 	mutex_lock(&info->qlock);
+	info->reset = false;
 	pthread_cond_wait(&info->qcond, &info->qlock);
 	mutex_unlock(&info->qlock);
 
-	if (pthread_create(&info->read_thr, NULL, avalon_get_results, (void *)avalon))
-		quit(1, "Failed to create avalon read_thr");
-
 	avalon_init(avalon);
 
 	cgtime(&now);