mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 07:17:58 +00:00
Make longpoll switch servers should it not match the current pool.
This commit is contained in:
parent
529aa70c38
commit
321c4798d4
30
main.c
30
main.c
@ -1989,9 +1989,19 @@ static void *longpoll_thread(void *userdata)
|
||||
|
||||
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
|
||||
|
||||
hdr_path = tq_pop(mythr->q, NULL);
|
||||
if (!hdr_path)
|
||||
curl = curl_easy_init();
|
||||
if (unlikely(!curl)) {
|
||||
applog(LOG_ERR, "CURL initialisation failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Longpoll sits waiting on next pushed url */
|
||||
next_path:
|
||||
hdr_path = tq_pop(mythr->q, NULL);
|
||||
if (!hdr_path) {
|
||||
applog(LOG_WARNING, "No long-poll found on this server");
|
||||
goto next_path;
|
||||
}
|
||||
|
||||
/* full URL */
|
||||
if (strstr(hdr_path, "://")) {
|
||||
@ -2011,14 +2021,9 @@ static void *longpoll_thread(void *userdata)
|
||||
|
||||
sprintf(lp_url, "%s%s%s", pool->rpc_url, need_slash ? "/" : "", copy_start);
|
||||
}
|
||||
free(hdr_path);
|
||||
|
||||
applog(LOG_INFO, "Long-polling activated for %s", lp_url);
|
||||
|
||||
curl = curl_easy_init();
|
||||
if (unlikely(!curl)) {
|
||||
applog(LOG_ERR, "CURL initialisation failed");
|
||||
goto out;
|
||||
}
|
||||
applog(LOG_WARNING, "Long-polling activated for %s", lp_url);
|
||||
|
||||
while (1) {
|
||||
struct timeval start, end;
|
||||
@ -2060,10 +2065,15 @@ static void *longpoll_thread(void *userdata)
|
||||
}
|
||||
}
|
||||
memcpy(longpoll_block, current_block, 36);
|
||||
if (pool != current_pool()) {
|
||||
applog(LOG_WARNING, "Attempting to change longpoll servers");
|
||||
pool = current_pool();
|
||||
have_longpoll = false;
|
||||
goto next_path;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
free(hdr_path);
|
||||
free(lp_url);
|
||||
tq_freeze(mythr->q);
|
||||
if (curl)
|
||||
|
2
util.c
2
util.c
@ -315,12 +315,14 @@ json_t *json_rpc_call(CURL *curl, const char *url,
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
if (!have_longpoll) {
|
||||
/* If X-Long-Polling was found, activate long polling */
|
||||
if (hi.lp_path) {
|
||||
have_longpoll = true;
|
||||
tq_push(thr_info[longpoll_thr_id].q, hi.lp_path);
|
||||
} else
|
||||
free(hi.lp_path);
|
||||
}
|
||||
hi.lp_path = NULL;
|
||||
|
||||
val = JSON_LOADS(all_data.buf, &err);
|
||||
|
Loading…
Reference in New Issue
Block a user