summaryrefslogtreecommitdiff
path: root/plugins/adaptername.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2011-07-20 12:12:22 +0300
committerJohan Hedberg <johan.hedberg@intel.com>2011-07-26 12:59:54 +0300
commite2482a5ee3626e426149558e27a8e50ad07d7dad (patch)
tree85fd545b932b932e2ae2f54aac4abff6328d5f35 /plugins/adaptername.c
parent9a7e2cc81cdea7a673a2cc29cd8eae43155122c0 (diff)
Fix removing inotify watch whenever an adapter is removed
This sometimes cause bluetoothd to burn cpu when an adapter is removed from the system. Since the watch is not really bond to any adapter, in fact it is added on plugin .init, its removal is now moved to plugin .exit.
Diffstat (limited to 'plugins/adaptername.c')
-rw-r--r--plugins/adaptername.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/plugins/adaptername.c b/plugins/adaptername.c
index 2a54cc0a..9e99e6a9 100644
--- a/plugins/adaptername.c
+++ b/plugins/adaptername.c
@@ -262,10 +262,6 @@ static gboolean handle_inotify_cb(GIOChannel *channel, GIOCondition cond,
static void adaptername_remove(struct btd_adapter *adapter)
{
- if (watch_fd >= 0)
- close(watch_fd);
- if (inotify != NULL)
- g_io_channel_shutdown(inotify, FALSE, NULL);
}
static struct btd_adapter_driver adaptername_driver = {
@@ -314,6 +310,13 @@ static int adaptername_init(void)
static void adaptername_exit(void)
{
+ if (watch_fd >= 0)
+ close(watch_fd);
+ if (inotify != NULL) {
+ g_io_channel_shutdown(inotify, FALSE, NULL);
+ g_io_channel_unref(inotify);
+ }
+
btd_unregister_adapter_driver(&adaptername_driver);
}