diff options
author | James McCoy <jamessan@jamessan.com> | 2017-01-27 16:11:49 -0500 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-01-28 10:54:04 +0100 |
commit | dbd365c3f9216a2fbddb28b124e277936316ef90 (patch) | |
tree | 967075d0438edde3abb883b1a724088eb1fdece0 /clients/nm-online.c | |
parent | 73b560c215806ab72b1473751ba729a3b5596d69 (diff) | |
download | NetworkManager-dbd365c3f9216a2fbddb28b124e277936316ef90.tar.gz |
nm-online: return from quit_if_connected after setting retval
c5f17a97ea8e4cee85c93ee9cfa04057f83e13ab changed nm-online to determine
the status asynchronously, however this introduced a regression with
"nm-online -x -q" when there is connectivity.
if ( state == NM_STATE_CONNECTED_LOCAL
|| state == NM_STATE_CONNECTED_SITE
|| state == NM_STATE_CONNECTED_GLOBAL) {
data->retval = 0;
g_main_loop_quit (data->loop);
}
}
if (data->exit_no_nm && (state != NM_STATE_CONNECTING)) {
data->retval = 1;
g_main_loop_quit (data->loop);
}
After setting data->retval = 0 in the "state is connected" branch, the
function falls through to the "exit_no_nm and !connecting" branch,
overwriting data->retval. This causes "nm-online -x -q" to incorrectly
report an offline state.
Adding an explicit "return;" after any state where data->retval is set
ensures that the value isn't overwritten before main() uses it.
Fixes: c5f17a97ea8e4cee85c93ee9cfa04057f83e13ab
https://mail.gnome.org/archives/networkmanager-list/2017-January/msg00058.html
Diffstat (limited to 'clients/nm-online.c')
-rw-r--r-- | clients/nm-online.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clients/nm-online.c b/clients/nm-online.c index 60ea41cba9..c1df195aaf 100644 --- a/clients/nm-online.c +++ b/clients/nm-online.c @@ -66,11 +66,13 @@ quit_if_connected (OnlineData *data) if (data->exit_no_nm) { data->retval = 1; g_main_loop_quit (data->loop); + return; } } else if (data->wait_startup) { if (!nm_client_get_startup (data->client)) { data->retval = 0; g_main_loop_quit (data->loop); + return; } } else { if ( state == NM_STATE_CONNECTED_LOCAL @@ -78,11 +80,13 @@ quit_if_connected (OnlineData *data) || state == NM_STATE_CONNECTED_GLOBAL) { data->retval = 0; g_main_loop_quit (data->loop); + return; } } if (data->exit_no_nm && (state != NM_STATE_CONNECTING)) { data->retval = 1; g_main_loop_quit (data->loop); + return; } } |