Fix race condition
This commit is contained in:
parent
385047779e
commit
6ae9a6a164
1 changed files with 7 additions and 4 deletions
11
pam_wlan.c
11
pam_wlan.c
|
@ -163,12 +163,16 @@ static NMDevice * find_device(NMClient *client) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void state_cb(NMActiveConnection *active_connection, GParamSpec *pspec, gpointer user_data) {
|
static void state_cb(NMDevice *device, GParamSpec *pspec, gpointer user_data) {
|
||||||
cb_arg *arg = user_data;
|
cb_arg *arg = user_data;
|
||||||
|
|
||||||
|
NMActiveConnection *active_connection = nm_device_get_active_connection(device);
|
||||||
|
if (!active_connection)
|
||||||
|
return;
|
||||||
|
|
||||||
NMActiveConnectionState state = nm_active_connection_get_state(active_connection);
|
NMActiveConnectionState state = nm_active_connection_get_state(active_connection);
|
||||||
|
|
||||||
if (state != NM_ACTIVE_CONNECTION_STATE_ACTIVATING) {
|
if (state != NM_ACTIVE_CONNECTION_STATE_ACTIVATING && state != NM_ACTIVE_CONNECTION_STATE_DEACTIVATING) {
|
||||||
if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED)
|
if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED)
|
||||||
arg->ret = PAM_SUCCESS;
|
arg->ret = PAM_SUCCESS;
|
||||||
|
|
||||||
|
@ -182,8 +186,6 @@ static void activate_cb(NMClient *client, NMActiveConnection *active_connection,
|
||||||
if (error)
|
if (error)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
g_signal_connect(active_connection, "notify::state", G_CALLBACK(state_cb), arg);
|
|
||||||
state_cb(active_connection, NULL, arg);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -201,6 +203,7 @@ static void add_cb(NMRemoteSettings *settings, NMRemoteConnection *con, GError *
|
||||||
if (!device)
|
if (!device)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
g_signal_connect(device, "notify::state", G_CALLBACK(state_cb), arg);
|
||||||
nm_client_activate_connection(arg->client, NM_CONNECTION(con), device, NULL, activate_cb, arg);
|
nm_client_activate_connection(arg->client, NM_CONNECTION(con), device, NULL, activate_cb, arg);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Reference in a new issue