summaryrefslogtreecommitdiff
path: root/emulator/hciemu.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2020-11-11 14:15:46 -0800
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2020-11-13 15:12:15 -0800
commit90cf5bf7748bb97da0355c4e081c193be8b57b45 (patch)
tree9132d433e4a50cfc0f1c2365b10f3ec3ffc07530 /emulator/hciemu.c
parentd3a7053267d9dfece12bb41678f86b392f0ced7f (diff)
downloadbluez-90cf5bf7748bb97da0355c4e081c193be8b57b45.tar.gz
hciemu: Fix crash when test is aborted during pre setup
If the tester_pre_setup_failed is called all timeout related to the test must be cancelled as the test should have been freed by the application and the next test is about to start.
Diffstat (limited to 'emulator/hciemu.c')
-rw-r--r--emulator/hciemu.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/emulator/hciemu.c b/emulator/hciemu.c
index fd6029deb..961de6359 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);