summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-12-22 19:33:41 -0300
committerJohan Hedberg <johan.hedberg@nokia.com>2008-12-22 11:36:21 +0200
commitad37d886cc54a9a975f0f5322165bbb2855dac7f (patch)
tree7958db7c3960c9ab35a4a886cc3fc92335ec9d1b /src/main.c
parent2310cdaf70c36422a95c0b1832decf86deb894bf (diff)
Cleanup adapters on exit.
When bluetoothd is terminated any remaining registered adapters should be unregistered (including proper D-Bus signal emition) and have their drivers removed. The adapters should also be brought down unless they were already up upon initialization.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/main.c b/src/main.c
index fb917c89..d67a2477 100644
--- a/src/main.c
+++ b/src/main.c
@@ -474,7 +474,7 @@ fail:
exit(1);
}
-static void device_devreg_setup(int dev_id)
+static void device_devreg_setup(int dev_id, gboolean devup)
{
struct hci_dev_info di;
@@ -484,7 +484,7 @@ static void device_devreg_setup(int dev_id)
return;
if (!hci_test_bit(HCI_RAW, &di.flags))
- manager_register_adapter(dev_id);
+ manager_register_adapter(dev_id, devup);
}
static void device_devup_setup(int dev_id)
@@ -521,9 +521,13 @@ static void init_all_devices(int ctl)
}
for (i = 0; i < dl->dev_num; i++, dr++) {
+ gboolean devup;
+
+ devup = hci_test_bit(HCI_UP, &dr->dev_opt);
+
info("HCI dev %d registered", dr->dev_id);
- device_devreg_setup(dr->dev_id);
- if (hci_test_bit(HCI_UP, &dr->dev_opt)) {
+ device_devreg_setup(dr->dev_id, devup);
+ if (devup) {
info("HCI dev %d already up", dr->dev_id);
device_devup_setup(dr->dev_id);
}
@@ -553,7 +557,7 @@ static inline void device_event(GIOChannel *chan, evt_stack_internal *si)
switch (sd->event) {
case HCI_DEV_REG:
info("HCI dev %d registered", sd->dev_id);
- device_devreg_setup(sd->dev_id);
+ device_devreg_setup(sd->dev_id, FALSE);
break;
case HCI_DEV_UNREG:
@@ -767,14 +771,14 @@ int main(int argc, char *argv[])
hcid_dbus_unregister();
+ hcid_dbus_exit();
+
plugin_cleanup();
stop_sdp_server();
agent_exit();
- hcid_dbus_exit();
-
g_main_loop_unref(event_loop);
if (config)