Provide a message and set a bool when no work is available from any pools and when it resumes again.
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
diff --git a/cgminer.c b/cgminer.c
index 4ea6d47..0c98f61 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -148,6 +148,7 @@ bool opt_api_listen;
bool opt_api_network;
bool opt_delaynet;
bool opt_disable_pool;
+static bool no_work;
char *opt_icarus_options = NULL;
char *opt_icarus_timing = NULL;
bool opt_worktime;
@@ -5484,8 +5485,28 @@ static struct work *hash_pop(void)
int hc;
mutex_lock(stgd_lock);
- while (!HASH_COUNT(staged_work))
- pthread_cond_wait(&getq->cond, stgd_lock);
+ while (!HASH_COUNT(staged_work)) {
+ if (!no_work) {
+ struct timespec then;
+ struct timeval now;
+ int rc;
+
+ cgtime(&now);
+ then.tv_sec = now.tv_sec + 5;
+ then.tv_nsec = now.tv_usec * 1000;
+ rc = pthread_cond_timedwait(&getq->cond, stgd_lock, &then);
+ if (rc) {
+ applog(LOG_WARNING, "Waiting for work to be available from pools.");
+ no_work = true;
+ }
+ } else
+ pthread_cond_wait(&getq->cond, stgd_lock);
+ }
+
+ if (no_work) {
+ applog(LOG_WARNING, "Work available from pools, resuming.");
+ no_work = false;
+ }
hc = HASH_COUNT(staged_work);
/* Find clone work if possible, to allow masters to be reused */