Skip to content

Commit

Permalink
Properly disable scan after scan_loop termination
Browse files Browse the repository at this point in the history
  • Loading branch information
avi-jois authored and oliviermartin committed Dec 7, 2020
1 parent c6c29ad commit 989483a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dbus/gattlib_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ int gattlib_adapter_scan_enable(void* adapter, gattlib_discovered_device_t disco
int gattlib_adapter_scan_disable(void* adapter) {
struct gattlib_adapter *gattlib_adapter = adapter;

if (gattlib_adapter->scan_loop && g_main_loop_is_running(gattlib_adapter->scan_loop)) {
if (gattlib_adapter->scan_loop) {

GError *error = NULL;

org_bluez_adapter1_call_stop_discovery_sync(gattlib_adapter->adapter_proxy, NULL, &error);
Expand All @@ -325,7 +326,9 @@ int gattlib_adapter_scan_disable(void* adapter) {
g_source_remove(gattlib_adapter->timeout_id);

// Ensure the scan loop is quit
g_main_loop_quit(gattlib_adapter->scan_loop);
if (g_main_loop_is_running(gattlib_adapter->scan_loop)) {
g_main_loop_quit(gattlib_adapter->scan_loop);
}
g_main_loop_unref(gattlib_adapter->scan_loop);
gattlib_adapter->scan_loop = NULL;
}
Expand Down

0 comments on commit 989483a

Please sign in to comment.