aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2012-04-28 16:16:56 +0100
committerJohan Hedberg <johan.hedberg@intel.com>2012-04-29 22:39:47 +0300
commita521540ca0f807b51ea881d5de7fb60bba592ffa (patch)
tree802f14249f9c34f2dedf3f7ac3538161c331128a
parent0c8e425395827785e6f3fcfd0df6af8a771f0565 (diff)
downloadbluez-a521540ca0f807b51ea881d5de7fb60bba592ffa.tar.gz
bluez-a521540ca0f807b51ea881d5de7fb60bba592ffa.tar.xz
bluez-a521540ca0f807b51ea881d5de7fb60bba592ffa.zip
Fix adaptername shutdown
An inotify watch descriptor isn't a file descriptor, so don't treat it as such and remove it properly.
-rw-r--r--plugins/adaptername.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/plugins/adaptername.c b/plugins/adaptername.c
index e154e92c..d3341b5f 100644
--- a/plugins/adaptername.c
+++ b/plugins/adaptername.c
@@ -52,7 +52,7 @@
#define MACHINE_INFO_FILE "machine-info"
static GIOChannel *inotify = NULL;
-static int watch_fd = -1;
+static int watch_d = -1;
/* This file is part of systemd's hostnamed functionality:
* http://0pointer.de/public/systemd-man/machine-info.html
@@ -292,8 +292,8 @@ static int adaptername_init(void)
mask |= IN_MOVED_FROM;
mask |= IN_MOVED_TO;
- watch_fd = inotify_add_watch(inot_fd, MACHINE_INFO_DIR, mask);
- if (watch_fd < 0) {
+ watch_d = inotify_add_watch(inot_fd, MACHINE_INFO_DIR, mask);
+ if (watch_d < 0) {
error("Failed to setup watch for '%s'", MACHINE_INFO_DIR);
close(inot_fd);
return 0;
@@ -310,8 +310,11 @@ static int adaptername_init(void)
static void adaptername_exit(void)
{
- if (watch_fd >= 0)
- close(watch_fd);
+ if (watch_d >= 0 && inotify != NULL) {
+ int inot_fd = g_io_channel_unix_get_fd(inotify);
+ inotify_rm_watch(inot_fd, watch_d);
+ }
+
if (inotify != NULL) {
g_io_channel_shutdown(inotify, FALSE, NULL);
g_io_channel_unref(inotify);