summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-09-25 02:13:07 +0200
committerMarcel Holtmann <marcel@holtmann.org>2008-09-25 02:13:07 +0200
commit5f3961abfd5e2ac3c614925dbf63b86c38899a0b (patch)
tree3db3c392f35adbf4112aae48cb83144a73ea662b
parentee33a0705e529b66d9e8fc85381bc2efa0e43457 (diff)
Fix crashes with suspend/resume
-rw-r--r--src/security.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/security.c b/src/security.c
index fd2535fd..964fb5ba 100644
--- a/src/security.c
+++ b/src/security.c
@@ -46,6 +46,7 @@
#include <dbus/dbus.h>
+#include "hcid.h"
#include "logging.h"
#include "textfile.h"
@@ -789,6 +790,20 @@ static inline void conn_request(int dev, bdaddr_t *sba, void *ptr)
write_remote_class(sba, &evt->bdaddr, class);
}
+static void delete_channel(GIOChannel *chan)
+{
+ int i;
+
+ /* Look for the GIOChannel in the table */
+ for (i = 0; i < HCI_MAX_DEV; i++)
+ if (io_data[i].channel == chan) {
+ stop_security_manager(i);
+ return;
+ }
+
+ error("IO channel not found in the io_data table");
+}
+
static gboolean io_security_event(GIOChannel *chan, GIOCondition cond, gpointer data)
{
unsigned char buf[HCI_MAX_EVENT_SIZE], *ptr = buf;
@@ -799,14 +814,14 @@ static gboolean io_security_event(GIOChannel *chan, GIOCondition cond, gpointer
GIOError err;
if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) {
- g_io_channel_unref(chan);
+ delete_channel(chan);
return FALSE;
}
if ((err = g_io_channel_read(chan, (gchar *) buf, sizeof(buf), &len))) {
if (err == G_IO_ERROR_AGAIN)
return TRUE;
- g_io_channel_unref(chan);
+ delete_channel(chan);
return FALSE;
}