mirror of
https://github.com/haproxy/haproxy.git
synced 2026-04-29 02:00:37 -04:00
BUG/MEDIUM: cli/shutdown sessions: make it thread-safe
There's no locking around the lookup of a stream nor its shutdown when issuing "shutdown sessions" over the CLI so the risk of crashing the process is particularly high. Let's use a thread_isolate() there which is suitable for this task, and there are not that many alternatives. This must be backported to 1.8.
This commit is contained in:
parent
92b887e20a
commit
3f5dd2945c
1 changed files with 7 additions and 2 deletions
|
|
@ -3444,17 +3444,22 @@ static int cli_parse_shutdown_session(char **args, char *payload, struct appctx
|
|||
|
||||
ptr = (void *)strtoul(args[2], NULL, 0);
|
||||
|
||||
thread_isolate();
|
||||
|
||||
/* first, look for the requested stream in the stream table */
|
||||
list_for_each_entry(strm, &streams, list) {
|
||||
if (strm == ptr)
|
||||
if (strm == ptr) {
|
||||
stream_shutdown(strm, SF_ERR_KILLED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
thread_release();
|
||||
|
||||
/* do we have the stream ? */
|
||||
if (strm != ptr)
|
||||
return cli_err(appctx, "No such session (use 'show sess').\n");
|
||||
|
||||
stream_shutdown(strm, SF_ERR_KILLED);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue