nm-online: fix wrong assertion failure during nm-online

_return() assigns the return value @retval and asserts that
currently no return-value is assigned -- in order not to overwrite
a once set value.

That requires, that we call _return() and exit the main-loop right
away, without possibility to call _return() again.

However, during client_properties_changed() we easily might
receive the "notify" signal multiple times, and thus call
quit_if_connected() and _return() multiple times. That would
lead to a wrong assertion failure.

Avoid that, by disconnecting the signal handler once we reach
_return().

Fixes: f7875a42b0
This commit is contained in:
Thomas Haller
2017-02-07 19:39:48 +01:00
parent ca5f915ac2
commit ec91f950b8

View File

@@ -77,6 +77,7 @@ _return (OnlineData *data, int retval)
nm_assert (data->retval == EXIT_FAILURE_UNSPECIFIED);
data->retval = retval;
nm_clear_g_signal_handler (data->client, &data->client_notify_id);
g_main_loop_quit (data->loop);
}
@@ -297,7 +298,7 @@ main (int argc, char *argv[])
g_clear_pointer (&data.loop, g_main_loop_unref);
if (!data.quiet)
_print_progress (-1, NM_MAX (0, data.end_timestamp_ms - _now_ms ()), data.retval == 0);
_print_progress (-1, NM_MAX (0, data.end_timestamp_ms - _now_ms ()), data.retval == EXIT_SUCCESS);
return data.retval;
}