mirror of
https://github.com/GOSTSec/sgminer
synced 2025-02-05 19:44:21 +00:00
Avoid getting more work if by the time the getwork thread is spawned we find ourselves with enough work.
This commit is contained in:
parent
07fca3e289
commit
c91a95459b
25
cgminer.c
25
cgminer.c
@ -2272,20 +2272,39 @@ static int global_queued(void)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool enough_work(void)
|
||||||
|
{
|
||||||
|
int cq, cs, ts, tq, maxq = opt_queue + mining_threads;
|
||||||
|
|
||||||
|
cq = current_queued();
|
||||||
|
cs = current_staged();
|
||||||
|
ts = total_staged();
|
||||||
|
tq = global_queued();
|
||||||
|
|
||||||
|
if (((cs || cq >= opt_queue) && ts >= maxq) ||
|
||||||
|
((cs || cq) && tq >= maxq))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* ce and pool may appear uninitialised at push_curl_entry, but they're always
|
/* ce and pool may appear uninitialised at push_curl_entry, but they're always
|
||||||
* set when we don't have opt_benchmark enabled */
|
* set when we don't have opt_benchmark enabled */
|
||||||
static void *get_work_thread(void *userdata)
|
static void *get_work_thread(void *userdata)
|
||||||
{
|
{
|
||||||
struct workio_cmd *wc = (struct workio_cmd *)userdata;
|
struct workio_cmd *wc = (struct workio_cmd *)userdata;
|
||||||
struct curl_ent * uninitialised_var(ce);
|
|
||||||
struct pool * uninitialised_var(pool);
|
struct pool * uninitialised_var(pool);
|
||||||
struct work *ret_work = make_work();
|
struct curl_ent *ce = NULL;
|
||||||
|
struct work *ret_work;
|
||||||
int failures = 0;
|
int failures = 0;
|
||||||
|
|
||||||
pthread_detach(pthread_self());
|
pthread_detach(pthread_self());
|
||||||
|
|
||||||
applog(LOG_DEBUG, "Creating extra get work thread");
|
applog(LOG_DEBUG, "Creating extra get work thread");
|
||||||
|
|
||||||
|
if (enough_work())
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
ret_work = make_work();
|
||||||
if (wc->thr)
|
if (wc->thr)
|
||||||
ret_work->thr = wc->thr;
|
ret_work->thr = wc->thr;
|
||||||
else
|
else
|
||||||
@ -2330,7 +2349,7 @@ static void *get_work_thread(void *userdata)
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
workio_cmd_free(wc);
|
workio_cmd_free(wc);
|
||||||
if (!opt_benchmark)
|
if (ce)
|
||||||
push_curl_entry(ce, pool);
|
push_curl_entry(ce, pool);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user