Browse Source

Timeout in 5 seconds on the stratum read socket allowing us to detect closed connections sooner

master
Con Kolivas 11 years ago
parent
commit
1ac5fec1ee
  1. 9
      src/generator.c
  2. 2
      src/libckpool.c

9
src/generator.c

@ -897,8 +897,8 @@ static void *proxy_recv(void *arg)
while (42) { while (42) {
notify_instance_t *ni, *tmp; notify_instance_t *ni, *tmp;
share_msg_t *share, *tmpshare; share_msg_t *share, *tmpshare;
int retries = 0, ret;
time_t now; time_t now;
int ret;
now = time(NULL); now = time(NULL);
@ -923,7 +923,12 @@ static void *proxy_recv(void *arg)
} }
mutex_unlock(&proxi->share_lock); mutex_unlock(&proxi->share_lock);
ret = read_socket_line(cs, 120); /* If we don't get an update within 2 minutes the upstream pool
* has likely stopped responding. */
do {
ret = read_socket_line(cs, 5);
} while (ret == 0 && ++retries < 24);
if (ret < 1) { if (ret < 1) {
LOGWARNING("Failed to read_socket_line in proxy_recv, attempting reconnect"); LOGWARNING("Failed to read_socket_line in proxy_recv, attempting reconnect");
reconnect_stratum(cs, proxi); reconnect_stratum(cs, proxi);

2
src/libckpool.c

@ -492,7 +492,7 @@ int read_socket_line(connsock_t *cs, int timeout)
continue; continue;
if (ret < 1) { if (ret < 1) {
if (!ret) if (!ret)
LOGNOTICE("Select timed out in read_socket_line"); LOGDEBUG("Select timed out in read_socket_line");
else else
LOGERR("Select failed in read_socket_line"); LOGERR("Select failed in read_socket_line");
goto out; goto out;

Loading…
Cancel
Save