diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2018-11-02 11:32:27 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2018-11-02 11:32:27 +0100 |
commit | e125d2406771dbb7c3985fb806088804fc5197ad (patch) | |
tree | 2474f0cf6c8add5b4c526faf074f247db937700c | |
parent | 4d0eca46f1e861e6c687ce738909dd21b05c58bb (diff) | |
download | NetworkManager-bg/cli-editor-rh1546805.tar.gz |
cli: wait for changed signal after updating a connectionbg/cli-editor-rh1546805
-rw-r--r-- | clients/cli/connections.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c index f296d182e9..96ae2cc495 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -6585,9 +6585,16 @@ typedef struct { } MonitorACInfo; static gboolean nmc_editor_cb_called; +static gboolean nmc_editor_connection_changed; static GError *nmc_editor_error; static MonitorACInfo *nmc_editor_monitor_ac; +static void +editor_connection_changed_cb (NMConnection *connection, void *unused) +{ + nmc_editor_connection_changed = TRUE; +} + /* * Store 'error' to shared 'nmc_editor_error' and monitoring info to * 'nmc_editor_monitor_ac' and signal the condition so that @@ -7212,6 +7219,7 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t gboolean temp_changes; GError *err1 = NULL; NmcEditorMenuContext menu_ctx = { 0 }; + gulong handler_id; s_con = nm_connection_get_setting_connection (connection); if (s_con) @@ -7764,10 +7772,20 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t update_connection (persistent, rem_con, update_connection_editor_cb, NULL); } - //FIXME: add also a timeout for cases the callback is not called + nmc_editor_connection_changed = FALSE; + handler_id = g_signal_connect (rem_con, + NM_CONNECTION_CHANGED, + G_CALLBACK (editor_connection_changed_cb), + NULL); + while (!nmc_editor_cb_called) g_main_context_iteration (NULL, TRUE); + while (!nmc_editor_connection_changed) + g_main_context_iteration (NULL, TRUE); + + g_signal_handler_disconnect (rem_con, handler_id); + if (nmc_editor_error) { g_print (_("Error: Failed to save '%s' (%s) connection: %s\n"), nm_connection_get_id (connection), |