From 914be773e620ef86cef8d5e56f8597045ba24f7f Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 13 Dec 2015 23:23:31 +1100 Subject: [PATCH] Detect old session clients with an empty array in proxy mode as well --- src/stratifier.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index dcc0b412..d98e37fd 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -3525,6 +3525,7 @@ static json_t *parse_subscribe(stratum_instance_t *client, const int64_t client_ { ckpool_t *ckp = client->ckp; sdata_t *sdata, *ckp_sdata = ckp->data; + int session_id = 0, userid = -1; bool old_match = false; char sessionid[12]; int arr_size; @@ -3547,7 +3548,6 @@ static json_t *parse_subscribe(stratum_instance_t *client, const int64_t client_ /* NOTE useragent is NULL prior to this so should not be used in code * till after this point */ if (arr_size > 0) { - int session_id = 0; const char *buf; buf = json_string_value(json_array_get(params_val, 0)); @@ -3571,26 +3571,26 @@ static json_t *parse_subscribe(stratum_instance_t *client, const int64_t client_ __fill_enonce1data(sdata->current_workbase, client); ck_runlock(&ckp_sdata->workbase_lock); } - } else if (ckp->proxy) { - int userid; - - /* Use the session_id to tell us which user this was. - * If it's not available, see if there's an IP address - * which matches a recently disconnected session. */ - if (session_id) - userid = userid_from_sessionid(ckp_sdata, session_id); - if (userid == -1) - userid = userid_from_sessionip(ckp_sdata, client->address); - if (userid != -1) { - sdata_t *user_sdata = select_sdata(ckp, ckp_sdata, userid); - - if (user_sdata) - sdata = user_sdata; - } } } else client->useragent = ckzalloc(1); + if (ckp->proxy) { + /* Use the session_id to tell us which user this was. + * If it's not available, see if there's an IP address + * which matches a recently disconnected session. */ + if (session_id) + userid = userid_from_sessionid(ckp_sdata, session_id); + if (userid == -1) + userid = userid_from_sessionip(ckp_sdata, client->address); + if (userid != -1) { + sdata_t *user_sdata = select_sdata(ckp, ckp_sdata, userid); + + if (user_sdata) + sdata = user_sdata; + } + } + client->sdata = sdata; if (ckp->proxy) { LOGINFO("Current %d, selecting proxy %d:%d for client %"PRId64, ckp_sdata->proxy->id,