mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-10 23:08:07 +00:00
Never wait indefinitely for a pthread conditional in the hash_pop loop in case the work scheduler misses the last wakeup.
This commit is contained in:
parent
31df767cc7
commit
3f9ccc1b27
33
cgminer.c
33
cgminer.c
@ -5915,26 +5915,21 @@ static struct work *hash_pop(void)
|
|||||||
|
|
||||||
mutex_lock(stgd_lock);
|
mutex_lock(stgd_lock);
|
||||||
while (!HASH_COUNT(staged_work)) {
|
while (!HASH_COUNT(staged_work)) {
|
||||||
if (!no_work) {
|
struct timespec then;
|
||||||
struct timespec then;
|
struct timeval now;
|
||||||
struct timeval now;
|
int rc;
|
||||||
int rc;
|
|
||||||
|
|
||||||
cgtime(&now);
|
cgtime(&now);
|
||||||
then.tv_sec = now.tv_sec + 10;
|
then.tv_sec = now.tv_sec + 10;
|
||||||
then.tv_nsec = now.tv_usec * 1000;
|
then.tv_nsec = now.tv_usec * 1000;
|
||||||
pthread_cond_signal(&gws_cond);
|
pthread_cond_signal(&gws_cond);
|
||||||
rc = pthread_cond_timedwait(&getq->cond, stgd_lock, &then);
|
rc = pthread_cond_timedwait(&getq->cond, stgd_lock, &then);
|
||||||
/* Check again for !no_work as multiple threads may be
|
/* Check again for !no_work as multiple threads may be
|
||||||
* waiting on this condition and another may set the
|
* waiting on this condition and another may set the
|
||||||
* bool separately. */
|
* bool separately. */
|
||||||
if (rc && !no_work) {
|
if (rc && !no_work) {
|
||||||
no_work = true;
|
no_work = true;
|
||||||
applog(LOG_WARNING, "Waiting for work to be available from pools.");
|
applog(LOG_WARNING, "Waiting for work to be available from pools.");
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pthread_cond_signal(&gws_cond);
|
|
||||||
pthread_cond_wait(&getq->cond, stgd_lock);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user