From a5ffba6d52310fdbd49933c0473dd5b27f46e145 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 21 Sep 2015 13:07:26 +1000 Subject: [PATCH 1/8] Increase default log buf size to fit mining notify messages --- src/libckpool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libckpool.h b/src/libckpool.h index aed291dc..d4b48747 100644 --- a/src/libckpool.h +++ b/src/libckpool.h @@ -192,7 +192,7 @@ static inline void flip_80(void *dest_p, const void *src_p) void logmsg(int loglevel, const char *fmt, ...); -#define DEFLOGBUFSIZ 512 +#define DEFLOGBUFSIZ 1024 #define LOGMSGBUF(__lvl, __buf) do { \ logmsg(__lvl, "%s", __buf); \ From c0e4310c2da247982ca86b24a8183be86ce5230f Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 21 Sep 2015 13:17:57 +1000 Subject: [PATCH 2/8] Send a dropall to the stratifier when we're in reject mode --- src/connector.c | 1 + src/stratifier.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/connector.c b/src/connector.c index 3107901c..a7b776ab 100644 --- a/src/connector.c +++ b/src/connector.c @@ -864,6 +864,7 @@ retry: } else if (cmdmatch(buf, "reject")) { LOGDEBUG("Connector received reject signal"); cdata->accept = false; + send_proc(ckp->stratifier, "dropall"); } else if (cmdmatch(buf, "stats")) { char *msg; diff --git a/src/stratifier.c b/src/stratifier.c index 243a9df9..5bdb9146 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1064,7 +1064,7 @@ static void drop_allclients(ckpool_t *ckp) ck_wunlock(&sdata->instance_lock); if (kills) - LOGNOTICE("Dropped %d instances", kills); + LOGNOTICE("Dropped %d instances for dropall request", kills); } static void update_subscribe(ckpool_t *ckp) From 3b9a84634011be606064024fa6795f493450c457 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 21 Sep 2015 13:40:42 +1000 Subject: [PATCH 3/8] Don't allow passthrough subclients to resume --- src/stratifier.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/stratifier.c b/src/stratifier.c index 5bdb9146..dc479330 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1370,6 +1370,12 @@ static stratum_instance_t *__stratum_add_instance(ckpool_t *ckp, const int64_t i return client; } +/* passthrough subclients have client_ids in the high bits */ +static inline bool passthrough_subclient(const int64_t client_id) +{ + return (client_id > 0xffffffffll); +} + static uint64_t disconnected_sessionid_exists(sdata_t *sdata, const char *sessionid, int *session_id, const int64_t id) { @@ -1378,6 +1384,10 @@ static uint64_t disconnected_sessionid_exists(sdata_t *sdata, const char *sessio uint64_t ret = 0; int slen; + /* Don't allow passthrough subclients to resume */ + if (passthrough_subclient(id)) + goto out; + if (!sessionid) goto out; slen = strlen(sessionid) / 2; From 581b3c8902cede037071f2a35ea352ad68c51b46 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 21 Sep 2015 15:34:11 +1000 Subject: [PATCH 4/8] 1024 is upper limit to be considered text by most editors so change down to 1000 --- src/libckpool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libckpool.h b/src/libckpool.h index d4b48747..9d8ba341 100644 --- a/src/libckpool.h +++ b/src/libckpool.h @@ -192,7 +192,7 @@ static inline void flip_80(void *dest_p, const void *src_p) void logmsg(int loglevel, const char *fmt, ...); -#define DEFLOGBUFSIZ 1024 +#define DEFLOGBUFSIZ 1000 #define LOGMSGBUF(__lvl, __buf) do { \ logmsg(__lvl, "%s", __buf); \ From 7d97b8d323de76469610762821399925032b70bc Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 21 Sep 2015 15:58:43 +1000 Subject: [PATCH 5/8] The stratifier shouldn't be broadcasting anything in passthrough mode --- src/stratifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stratifier.c b/src/stratifier.c index dc479330..7073f97a 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1773,7 +1773,7 @@ retry: LOGDEBUG("%ds elapsed in strat_loop, updating gbt base", ckp->update_interval); update_base(ckp, GEN_NORMAL); - } else { + } else if (!ckp->passthrough) { LOGDEBUG("%ds elapsed in strat_loop, pinging miners", ckp->update_interval); broadcast_ping(sdata); From 0d6fb758d698c9f0873c0d6a7338760c3d19db9b Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 21 Sep 2015 16:18:24 +1000 Subject: [PATCH 6/8] Timeout should be updated on each loop in proxy_recv --- src/generator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generator.c b/src/generator.c index 760f11e0..0336d257 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1290,8 +1290,8 @@ static void *proxy_recv(void *arg) /* If we don't get an update within 10 minutes the upstream pool * has likely stopped responding. */ - timeout = 10; do { + timeout = 10; if (cs->fd == -1) { ret = -1; break; From 88e78a02da9d261e297903904daff77b2045db86 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 21 Sep 2015 16:22:09 +1000 Subject: [PATCH 7/8] Cope with read_socket_line timeouts properly in generator --- src/generator.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/generator.c b/src/generator.c index 0336d257..c8fec756 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1261,9 +1261,9 @@ static void *proxy_recv(void *arg) while (42) { notify_instance_t *ni, *tmp; share_msg_t *share, *tmpshare; - int retries = 0, ret; float timeout; time_t now; + int ret; now = time(NULL); @@ -1290,14 +1290,14 @@ static void *proxy_recv(void *arg) /* If we don't get an update within 10 minutes the upstream pool * has likely stopped responding. */ + timeout = 600; do { - timeout = 10; if (cs->fd == -1) { ret = -1; break; } ret = read_socket_line(cs, &timeout); - } while (ret == 0 && ++retries < 120); + } while (ret == 0 && timeout > 0); if (ret < 1) { /* Send ourselves a reconnect message */ @@ -1403,7 +1403,7 @@ static void *passthrough_recv(void *arg) do { ret = read_socket_line(cs, &timeout); - } while (ret == 0); + } while (ret == 0 && timeout > 0); if (ret < 1) { /* Send ourselves a reconnect message */ From 83f111ae94010e61853745333aaf52c4927e9d98 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 21 Sep 2015 16:40:30 +1000 Subject: [PATCH 8/8] Make passthrough connection log to console --- src/generator.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/generator.c b/src/generator.c index c8fec756..27df2509 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1538,12 +1538,13 @@ retry: } cs = alive->cs; - LOGNOTICE("Connected to upstream server %s:%s as proxy%s", cs->url, cs->port, - ckp->passthrough ? " in passthrough mode" : ""); if (ckp->passthrough) { + LOGWARNING("Connected to upstream server %s:%s as proxy in passthrough mode", + cs->url, cs->port); create_pthread(&alive->pth_precv, passthrough_recv, alive); alive->passsends = create_ckmsgq(ckp, "passsend", &passthrough_send); } else { + LOGNOTICE("Connected to upstream server %s:%s as proxy", cs->url, cs->port); create_pthread(&alive->pth_precv, proxy_recv, alive); mutex_init(&alive->psend_lock); cond_init(&alive->psend_cond);