mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-09 06:18:06 +00:00
core: allow changing TCP keepalive packet idle time using tcp-keepalive
command-line option or config-file option.
This may be useful in certain scenarios. However, server load from keepalive
is increased 6-fold if code is hard-changed from 30 to 5. So, provide it as
an option instead, and use the previous value as a default (30).
Explanation from
015c064396
Kevin's middlecoin fix, CURL TCP keepalive constants lowered:
CURLOPT_TCP_KEEPIDLE from 45 to 5 and CURLOPT_TCP_KEEPINTVL from 30 to
5. Before it'd trigger a keepalive packet after 45 seconds of connection
idle time and then again every 30 seconds. Now it triggers a keepalive
packet after 5 seconds of connection idle time and then again every 5
seconds.
It makes the client more resilient against coin switching pools or just
pools with connection issues in general. It will however add a tiny bit
pressure to the pool server; but a TCP keepalive probe is only about
60-80 bytes, so I don't think it is an issue.
This commit is contained in:
parent
bb5065b601
commit
e4680ab627
13
cgminer.c
13
cgminer.c
@ -135,6 +135,11 @@ bool opt_delaynet;
|
||||
bool opt_disable_pool;
|
||||
static bool no_work;
|
||||
bool opt_worktime;
|
||||
#if defined(HAVE_LIBCURL) && defined(CURL_HAS_KEEPALIVE)
|
||||
int opt_tcp_keepalive = 30;
|
||||
#else
|
||||
int opt_tcp_keepalive;
|
||||
#endif
|
||||
|
||||
char *opt_kernel_path;
|
||||
char *cgminer_path;
|
||||
@ -1176,6 +1181,14 @@ static struct opt_table opt_config_table[] = {
|
||||
opt_set_bool, &use_syslog,
|
||||
"Use system log for output messages (default: standard error)"),
|
||||
#endif
|
||||
OPT_WITH_ARG("--tcp-keepalive",
|
||||
set_int_0_to_9999, opt_show_intval, &opt_tcp_keepalive,
|
||||
#if defined(HAVE_LIBCURL) && defined(CURL_HAS_KEEPALIVE)
|
||||
"TCP keepalive packet idle time"
|
||||
#else
|
||||
opt_hidden
|
||||
#endif
|
||||
),
|
||||
#ifdef HAVE_ADL
|
||||
OPT_WITH_ARG("--temp-cutoff",
|
||||
set_temp_cutoff, opt_show_intval, &opt_cutofftemp,
|
||||
|
1
miner.h
1
miner.h
@ -971,6 +971,7 @@ extern bool opt_delaynet;
|
||||
extern bool opt_restart;
|
||||
extern bool opt_worktime;
|
||||
extern int swork_id;
|
||||
extern int opt_tcp_keepalive;
|
||||
|
||||
#if LOCK_TRACKING
|
||||
extern pthread_mutex_t lockstat_lock;
|
||||
|
6
util.c
6
util.c
@ -255,13 +255,11 @@ static void set_nettime(void)
|
||||
#if CURL_HAS_KEEPALIVE
|
||||
static void keep_curlalive(CURL *curl)
|
||||
{
|
||||
const int tcp_keepidle = 45;
|
||||
const int tcp_keepintvl = 30;
|
||||
const long int keepalive = 1;
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, keepalive);
|
||||
curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, tcp_keepidle);
|
||||
curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, tcp_keepintvl);
|
||||
curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, opt_tcp_keepalive);
|
||||
curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, opt_tcp_keepalive);
|
||||
}
|
||||
#else
|
||||
static void keep_curlalive(CURL *curl)
|
||||
|
Loading…
Reference in New Issue
Block a user