From 8631f3380988656e559cd0c3e16bec4e090cdcd1 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 12 May 2014 22:49:39 +1000 Subject: [PATCH] Accept ping requests on the various unix sockets --- src/ckpool.c | 4 ++++ src/connector.c | 9 ++++++++- src/generator.c | 3 +++ src/stratifier.c | 12 ++++++++++-- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/ckpool.c b/src/ckpool.c index 0b642dc8..a0ef18f3 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -54,6 +54,10 @@ retry: close(sockd); goto out; } + if (!strncasecmp(buf, "ping", 4)) { + LOGDEBUG("Listener received ping request"); + send_unix_msg(sockd, "pong"); + } close(sockd); goto retry; out: diff --git a/src/connector.c b/src/connector.c index 95c3d27c..c9746688 100644 --- a/src/connector.c +++ b/src/connector.c @@ -455,11 +455,18 @@ retry: } buf = recv_unix_msg(sockd); - close(sockd); if (!buf) { + close(sockd); LOGWARNING("Failed to get message in connector_loop"); goto retry; } + if (!strncasecmp(buf, "ping", 4)) { + LOGDEBUG("Connector received ping request"); + send_unix_msg(sockd, "pong"); + close(sockd); + goto retry; + } + LOGDEBUG("Connector received message: %s", buf); if (!strncasecmp(buf, "shutdown", 8)) goto out; diff --git a/src/generator.c b/src/generator.c index 990bc165..fd39fc84 100644 --- a/src/generator.c +++ b/src/generator.c @@ -89,6 +89,9 @@ retry: if (submit_block(cs, buf + 12)) send_proc(&ckp->stratifier, "update"); /* FIXME Add logging of block solves */ + } else if (!strncasecmp(buf, "ping", 4)) { + LOGDEBUG("Generator received ping request"); + send_unix_msg(sockd, "pong"); } close(sockd); goto retry; diff --git a/src/stratifier.c b/src/stratifier.c index 861062cd..74c42299 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -669,11 +669,19 @@ retry: dealloc(buf); buf = recv_unix_msg(sockd); - close(sockd); if (!buf) { - LOGWARNING("Failed to get message in strat_loop"); + close(sockd); + LOGWARNING("Failed to get message in stratum_loop"); + goto retry; + } + if (!strncasecmp(buf, "ping", 4)) { + LOGDEBUG("Stratifier received ping request"); + send_unix_msg(sockd, "pong"); + close(sockd); goto retry; } + + close(sockd); LOGDEBUG("Stratifier received request: %s", buf); if (!strncasecmp(buf, "shutdown", 8)) { ret = 0;