summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2018-03-30 12:04:12 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2018-04-18 15:22:12 +0200
commit5f8737bdd53355609e5d35267c7800618b167606 (patch)
tree14bc5cc18b61766285f53225711af639749e7833 /shared
parent8c3023d471ffa459b33aa8a8df3c279a9b7e3d84 (diff)
downloadNetworkManager-5f8737bdd53355609e5d35267c7800618b167606.tar.gz
shared: fix nmtst_main_loop_run()
If the main loop is quit before the timeout expires, we leave the timeout source running on the main loop context. Since we usually create the main loop using the default context, the source will fire on the next main loop we create during the test. Therefore, destroy the timeout source if it is still active. Fixes: 766f31507b02c4721bdbabdc79755ff23652d6c6
Diffstat (limited to 'shared')
-rw-r--r--shared/nm-utils/nm-test-utils.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/shared/nm-utils/nm-test-utils.h b/shared/nm-utils/nm-test-utils.h
index f44f49d835..cc33a1aef5 100644
--- a/shared/nm-utils/nm-test-utils.h
+++ b/shared/nm-utils/nm-test-utils.h
@@ -933,7 +933,7 @@ _nmtst_main_loop_run_timeout (gpointer user_data)
}
static inline gboolean
-nmtst_main_loop_run (GMainLoop *loop, int timeout_ms)
+nmtst_main_loop_run (GMainLoop *loop, guint timeout_ms)
{
GSource *source = NULL;
guint id = 0;
@@ -949,6 +949,9 @@ nmtst_main_loop_run (GMainLoop *loop, int timeout_ms)
g_main_loop_run (loop);
+ if (source && loopx)
+ g_source_destroy (source);
+
/* if the timeout was reached, return FALSE. */
return loopx != NULL;
}