diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2006-02-17 15:20:51 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2006-02-17 15:20:51 +0000 |
commit | ea6e51d583bde53514e7589267ba55f55b8a23e6 (patch) | |
tree | eb295d06b0413f4227e92065089ab1e5b5043fe3 /hcid | |
parent | 66988386d4c05270a03f93257fdbbeac9bf047f0 (diff) |
Fix handling of D-Bus disconnect signal
Diffstat (limited to 'hcid')
-rw-r--r-- | hcid/main.c | 1 | ||||
-rw-r--r-- | hcid/security.c | 21 |
2 files changed, 15 insertions, 7 deletions
diff --git a/hcid/main.c b/hcid/main.c index 2c307176..7ea829af 100644 --- a/hcid/main.c +++ b/hcid/main.c @@ -666,6 +666,7 @@ int main(int argc, char *argv[], char *env[]) set_title("processing events"); ctl_io = g_io_channel_unix_new(hcid.sock); + g_io_add_watch(ctl_io, G_IO_IN, io_stack_event, NULL); /* Start event processor */ diff --git a/hcid/security.c b/hcid/security.c index 58b049ed..2c76f167 100644 --- a/hcid/security.c +++ b/hcid/security.c @@ -51,7 +51,12 @@ #include "hcid.h" #include "lib.h" -static GIOChannel *io_chan[HCI_MAX_DEV]; +struct g_io_info { + GIOChannel *channel; + int watch_id; +}; + +static struct g_io_info io_data[HCI_MAX_DEV]; static int pairing; @@ -701,7 +706,7 @@ static gboolean io_security_event(GIOChannel *chan, GIOCondition cond, gpointer void start_security_manager(int hdev) { - GIOChannel *chan = io_chan[hdev]; + GIOChannel *chan = io_data[hdev].channel; struct hci_dev_info *di; struct hci_filter flt; read_stored_link_key_cp cp; @@ -761,10 +766,10 @@ void start_security_manager(int hdev) } chan = g_io_channel_unix_new(dev); - g_io_add_watch(chan, G_IO_IN | G_IO_NVAL | G_IO_HUP | G_IO_ERR, - io_security_event, (void *) di); + io_data[hdev].watch_id = g_io_add_watch(chan, G_IO_IN | G_IO_NVAL | G_IO_HUP | G_IO_ERR, + io_security_event, (void *) di); - io_chan[hdev] = chan; + io_data[hdev].channel = chan; if (hci_test_bit(HCI_RAW, &di->flags)) return; @@ -778,7 +783,7 @@ void start_security_manager(int hdev) void stop_security_manager(int hdev) { - GIOChannel *chan = io_chan[hdev]; + GIOChannel *chan = io_data[hdev].channel; if (!chan) return; @@ -789,7 +794,9 @@ void stop_security_manager(int hdev) loop to call us right back with G_IO_NVAL set, at which point we will see it and clean things up */ close(g_io_channel_unix_get_fd(chan)); - io_chan[hdev] = NULL; + g_io_remove_watch(io_data[hdev].watch_id); + io_data[hdev].watch_id = -1; + io_data[hdev].channel = NULL; } void init_security_data(void) |