Browse Source

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.
nfactor-troky
Noel Maersk 11 years ago
parent
commit
e4680ab627
  1. 13
      cgminer.c
  2. 1
      miner.h
  3. 6
      util.c

13
cgminer.c

@ -135,6 +135,11 @@ bool opt_delaynet; @@ -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[] = { @@ -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

@ -971,6 +971,7 @@ extern bool opt_delaynet; @@ -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

@ -255,13 +255,11 @@ static void set_nettime(void) @@ -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…
Cancel
Save