If inquiry is active when bluetoothd starts up, it will get an error from the HCI layer when it tries to execute the StartDiscovery dbus call. This error in turn will prevent the list of devices which have been discovered and reported over dbus from being cleared, which will make many devices undiscoverable. This patch handles the case where the adapter is in periodic inquiry mode. It detects an attempt to change the adapter to a discovering state when there is no list of discovery sessions present, and issues the appropriate cancel_{periodic_,}discovery command. --- src/adapter.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 614a430..3146d8c 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -2469,6 +2469,20 @@ void adapter_set_state(struct btd_adapter *adapter, int state) (GSourceFunc) start_inquiry, adapter); + /* If we are discovering and have no discovery sessions, run away */ + if (discov_active && !adapter->disc_sessions) { + debug("discovery active without discovery sessions"); + if (state & PERIODIC_INQUIRY) { + debug("cancel_periodic_discovery"); + cancel_periodic_discovery(adapter); + } + if (state & STD_INQUIRY) { + debug("cancel_discovery"); + cancel_discovery(adapter); + } + return; + } + /* Send out of range */ if (!discov_active) adapter_update_oor_devices(adapter); -- 1.5.6.5 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html