Browse Source

Set client user_instance under lock to prevent race upon client removal

master
Con Kolivas 10 years ago
parent
commit
10613ecc76
  1. 3
      src/stratifier.c

3
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++; user->id = sdata->user_instance_id++;
HASH_ADD_STR(sdata->user_instances, username, user); HASH_ADD_STR(sdata->user_instances, username, user);
} }
client->user_instance = user;
DL_FOREACH(user->worker_instances, tmp) { DL_FOREACH(user->worker_instances, tmp) {
if (!safecmp(workername, tmp->workername)) { if (!safecmp(workername, tmp->workername)) {
client->worker_instance = tmp; 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"); *err_val = json_string("Invalid character in username");
goto out; goto out;
} }
user = client->user_instance = generate_user(ckp, client, buf); user = generate_user(ckp, client, buf);
client->user_id = user->id; client->user_id = user->id;
ts_realtime(&now); ts_realtime(&now);
client->start_time = now.tv_sec; client->start_time = now.tv_sec;

Loading…
Cancel
Save