1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-11 07:17:58 +00:00

Use keepalive with stratum sockets to improve its ability to detect broken connections.

This commit is contained in:
Con Kolivas 2012-10-28 09:15:45 +11:00
parent d9276557f1
commit aa97e87a13

14
util.c
View File

@ -196,11 +196,10 @@ out:
return ptrlen; return ptrlen;
} }
int json_rpc_call_sockopt_cb(void __maybe_unused *userdata, curl_socket_t fd, static int keep_sockalive(SOCKETTYPE fd)
curlsocktype __maybe_unused purpose)
{ {
int tcp_keepidle = 120; int tcp_keepidle = 60;
int tcp_keepintvl = 120; int tcp_keepintvl = 60;
#ifndef WIN32 #ifndef WIN32
int keepalive = 1; int keepalive = 1;
@ -244,6 +243,12 @@ int json_rpc_call_sockopt_cb(void __maybe_unused *userdata, curl_socket_t fd,
return 0; return 0;
} }
int json_rpc_call_sockopt_cb(void __maybe_unused *userdata, curl_socket_t fd,
curlsocktype __maybe_unused purpose)
{
return keep_sockalive(fd);
}
static void last_nettime(struct timeval *last) static void last_nettime(struct timeval *last)
{ {
rd_lock(&netacc_lock); rd_lock(&netacc_lock);
@ -1347,6 +1352,7 @@ bool initiate_stratum(struct pool *pool)
goto out; goto out;
} }
curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, (long *)&pool->sock); curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, (long *)&pool->sock);
keep_sockalive(pool->sock);
sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": []}", swork_id++); sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": []}", swork_id++);