Diff between d3a7053267d9dfece12bb41678f86b392f0ced7f and 90cf5bf7748bb97da0355c4e081c193be8b57b45

Changed Files

File Additions Deletions Status
emulator/hciemu.c +7 -1 modified
src/shared/tester.c +5 -0 modified

Full Patch

diff --git a/emulator/hciemu.c b/emulator/hciemu.c
index fd6029d..961de63 100644
--- a/emulator/hciemu.c
+++ b/emulator/hciemu.c
@@ -43,6 +43,7 @@ struct hciemu {
 	guint host_source;
 	guint master_source;
 	guint client_source;
+	guint start_source;
 	struct queue *post_command_hooks;
 	char bdaddr_str[18];
 
@@ -297,6 +298,8 @@ static gboolean start_stack(gpointer user_data)
 {
 	struct hciemu *hciemu = user_data;
 
+	hciemu->start_source = 0;
+
 	bthost_start(hciemu->host_stack);
 
 	return FALSE;
@@ -353,7 +356,7 @@ struct hciemu *hciemu_new(enum hciemu_type type)
 		return NULL;
 	}
 
-	g_idle_add(start_stack, hciemu);
+	hciemu->start_source = g_idle_add(start_stack, hciemu);
 
 	return hciemu_ref(hciemu);
 }
@@ -378,6 +381,9 @@ void hciemu_unref(struct hciemu *hciemu)
 
 	queue_destroy(hciemu->post_command_hooks, destroy_command_hook);
 
+	if (hciemu->start_source)
+		g_source_remove(hciemu->start_source);
+
 	g_source_remove(hciemu->host_source);
 	g_source_remove(hciemu->client_source);
 	g_source_remove(hciemu->master_source);
diff --git a/src/shared/tester.c b/src/shared/tester.c
index 0c31e8b..af33a79 100644
--- a/src/shared/tester.c
+++ b/src/shared/tester.c
@@ -541,6 +541,11 @@ void tester_pre_setup_failed(void)
 	if (test->stage != TEST_STAGE_PRE_SETUP)
 		return;
 
+	if (test->timeout_id > 0) {
+		g_source_remove(test->timeout_id);
+		test->timeout_id = 0;
+	}
+
 	print_progress(test->name, COLOR_RED, "pre setup failed");
 
 	g_idle_add(done_callback, test);