From 10613ecc7688c3f843053e669aa128eaaed3a13f Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 30 Jan 2015 11:44:20 +1100 Subject: [PATCH] Set client user_instance under lock to prevent race upon client removal --- src/stratifier.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/stratifier.c b/src/stratifier.c index fce0b8ed..222429bc 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -2201,6 +2201,7 @@ static user_instance_t *generate_user(ckpool_t *ckp, stratum_instance_t *client, user->id = sdata->user_instance_id++; HASH_ADD_STR(sdata->user_instances, username, user); } + client->user_instance = user; DL_FOREACH(user->worker_instances, tmp) { if (!safecmp(workername, tmp->workername)) { client->worker_instance = tmp; @@ -2411,7 +2412,7 @@ static json_t *parse_authorise(stratum_instance_t *client, const json_t *params_ *err_val = json_string("Invalid character in username"); goto out; } - user = client->user_instance = generate_user(ckp, client, buf); + user = generate_user(ckp, client, buf); client->user_id = user->id; ts_realtime(&now); client->start_time = now.tv_sec;