wpa_cli: Fix detach race with forked monitor process
Need to kill the monitor process before running detach command on the monitor connection to avoid race where the monitor process may end up getting the detach command result.
This commit is contained in:
parent
dd63f314bd
commit
037f83eb44
1 changed files with 9 additions and 8 deletions
|
@ -255,6 +255,15 @@ static void wpa_cli_close_connection(void)
|
||||||
if (ctrl_conn == NULL)
|
if (ctrl_conn == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef CONFIG_WPA_CLI_FORK
|
||||||
|
if (mon_pid) {
|
||||||
|
int status;
|
||||||
|
kill(mon_pid, SIGPIPE);
|
||||||
|
wait(&status);
|
||||||
|
mon_pid = 0;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_WPA_CLI_FORK */
|
||||||
|
|
||||||
if (wpa_cli_attached) {
|
if (wpa_cli_attached) {
|
||||||
wpa_ctrl_detach(interactive ? mon_conn : ctrl_conn);
|
wpa_ctrl_detach(interactive ? mon_conn : ctrl_conn);
|
||||||
wpa_cli_attached = 0;
|
wpa_cli_attached = 0;
|
||||||
|
@ -265,14 +274,6 @@ static void wpa_cli_close_connection(void)
|
||||||
wpa_ctrl_close(mon_conn);
|
wpa_ctrl_close(mon_conn);
|
||||||
mon_conn = NULL;
|
mon_conn = NULL;
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_WPA_CLI_FORK
|
|
||||||
if (mon_pid) {
|
|
||||||
int status;
|
|
||||||
kill(mon_pid, SIGPIPE);
|
|
||||||
wait(&status);
|
|
||||||
mon_pid = 0;
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_WPA_CLI_FORK */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue