mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-20 03:30:31 +00:00
We shouldn't block on no work situations directly from the getwork scheduler itself.
This commit is contained in:
parent
b9b3abe264
commit
a825524325
48
sgminer.c
48
sgminer.c
@ -5713,29 +5713,35 @@ static void pool_resus(struct pool *pool)
|
|||||||
applog(LOG_INFO, "%s alive", pool->poolname);
|
applog(LOG_INFO, "%s alive", pool->poolname);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct work *hash_pop(void)
|
/* If this is called non_blocking, it will return NULL for work so that must
|
||||||
|
* be handled. */
|
||||||
|
static struct work *hash_pop(bool blocking)
|
||||||
{
|
{
|
||||||
struct work *work = NULL, *tmp;
|
struct work *work = NULL, *tmp;
|
||||||
int hc;
|
int hc;
|
||||||
|
|
||||||
mutex_lock(stgd_lock);
|
mutex_lock(stgd_lock);
|
||||||
while (!HASH_COUNT(staged_work)) {
|
if (!HASH_COUNT(staged_work)) {
|
||||||
struct timespec then;
|
if (!blocking)
|
||||||
struct timeval now;
|
goto out_unlock;
|
||||||
int rc;
|
do {
|
||||||
|
struct timespec then;
|
||||||
|
struct timeval now;
|
||||||
|
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.");
|
||||||
}
|
}
|
||||||
|
} while (!HASH_COUNT(staged_work));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (no_work) {
|
if (no_work) {
|
||||||
@ -5764,6 +5770,7 @@ static struct work *hash_pop(void)
|
|||||||
|
|
||||||
/* Keep track of last getwork grabbed */
|
/* Keep track of last getwork grabbed */
|
||||||
last_getwork = time(NULL);
|
last_getwork = time(NULL);
|
||||||
|
out_unlock:
|
||||||
mutex_unlock(stgd_lock);
|
mutex_unlock(stgd_lock);
|
||||||
|
|
||||||
return work;
|
return work;
|
||||||
@ -5918,7 +5925,7 @@ struct work *get_work(struct thr_info *thr, const int thr_id)
|
|||||||
applog(LOG_DEBUG, "Popping work from get queue to get work");
|
applog(LOG_DEBUG, "Popping work from get queue to get work");
|
||||||
diff_t = time(NULL);
|
diff_t = time(NULL);
|
||||||
while (!work) {
|
while (!work) {
|
||||||
work = hash_pop();
|
work = hash_pop(true);
|
||||||
if (stale_work(work, false)) {
|
if (stale_work(work, false)) {
|
||||||
discard_work(work);
|
discard_work(work);
|
||||||
work = NULL;
|
work = NULL;
|
||||||
@ -8178,8 +8185,9 @@ begin_bench:
|
|||||||
/* Keeps slowly generating work even if it's not being
|
/* Keeps slowly generating work even if it's not being
|
||||||
* used to keep last_getwork incrementing and to see
|
* used to keep last_getwork incrementing and to see
|
||||||
* if pools are still alive. */
|
* if pools are still alive. */
|
||||||
work = hash_pop();
|
work = hash_pop(false);
|
||||||
discard_work(work);
|
if (work)
|
||||||
|
discard_work(work);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user