mirror of
https://github.com/GOSTSec/sgminer
synced 2025-09-03 09:42:17 +00:00
Don't waste the work we retrieve from a longpoll.
This commit is contained in:
parent
0c253734e1
commit
d53ee8e71b
25
main.c
25
main.c
@ -1802,6 +1802,30 @@ static void restart_threads(bool longpoll)
|
|||||||
work_restart[i].restart = 1;
|
work_restart[i].restart = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Stage another work item from the work returned in a longpoll */
|
||||||
|
static void convert_to_work(json_t *val)
|
||||||
|
{
|
||||||
|
struct work *work;
|
||||||
|
bool rc;
|
||||||
|
|
||||||
|
work = calloc(sizeof(*work), 1);
|
||||||
|
if (unlikely(!work)) {
|
||||||
|
applog(LOG_ERR, "OOM in convert_to_work");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc= work_decode(json_object_get(val, "result"), work);
|
||||||
|
if (unlikely(!rc)) {
|
||||||
|
applog(LOG_ERR, "Could not convert longpoll data to work");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unlikely(!tq_push(thr_info[stage_thr_id].q, work)))
|
||||||
|
applog(LOG_ERR, "Could not tq_push work in convert_to_work");
|
||||||
|
else if (opt_debug)
|
||||||
|
applog(LOG_DEBUG, "Converted longpoll data to work");
|
||||||
|
}
|
||||||
|
|
||||||
static void *longpoll_thread(void *userdata)
|
static void *longpoll_thread(void *userdata)
|
||||||
{
|
{
|
||||||
struct thr_info *mythr = userdata;
|
struct thr_info *mythr = userdata;
|
||||||
@ -1851,6 +1875,7 @@ static void *longpoll_thread(void *userdata)
|
|||||||
val = json_rpc_call(curl, lp_url, rpc_userpass, rpc_req,
|
val = json_rpc_call(curl, lp_url, rpc_userpass, rpc_req,
|
||||||
false, true);
|
false, true);
|
||||||
if (likely(val)) {
|
if (likely(val)) {
|
||||||
|
convert_to_work(val);
|
||||||
failures = 0;
|
failures = 0;
|
||||||
json_decref(val);
|
json_decref(val);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user