summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2011-08-06 10:58:59 +0200
committerMarcel Holtmann <marcel@holtmann.org>2011-08-06 12:53:50 +0200
commit64d90e9fa7002f13c9232c4cbabf10d9cf93121a (patch)
tree86f1756ac4d11f7a5139020a962bb66067ef4c0b
parent52ac1749e0d609781a11297c033ed8ce2ac0b136 (diff)
downloadofono-64d90e9fa7002f13c9232c4cbabf10d9cf93121a.tar.bz2
udev: Add warning in case channel gets disconnected
-rw-r--r--plugins/udevng.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/plugins/udevng.c b/plugins/udevng.c
index 933527dd..d9992321 100644
--- a/plugins/udevng.c
+++ b/plugins/udevng.c
@@ -467,6 +467,9 @@ static void enumerate_devices(struct udev *context)
g_hash_table_foreach(modem_list, create_modem, NULL);
}
+static struct udev *udev_ctx;
+static struct udev_monitor *udev_mon;
+static guint udev_watch = 0;
static guint udev_delay = 0;
static gboolean check_modem_list(gpointer user_data)
@@ -480,14 +483,19 @@ static gboolean check_modem_list(gpointer user_data)
return FALSE;
}
-static gboolean udev_event(GIOChannel *channel,
- GIOCondition condition, gpointer user_data)
+static gboolean udev_event(GIOChannel *channel, GIOCondition cond,
+ gpointer user_data)
{
- struct udev_monitor *monitor = user_data;
struct udev_device *device;
const char *action;
- device = udev_monitor_receive_device(monitor);
+ if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) {
+ ofono_warn("Error with udev monitor channel");
+ udev_watch = 0;
+ return FALSE;
+ }
+
+ device = udev_monitor_receive_device(udev_mon);
if (device == NULL)
return TRUE;
@@ -510,10 +518,6 @@ static gboolean udev_event(GIOChannel *channel,
return TRUE;
}
-static struct udev *udev_ctx;
-static struct udev_monitor *udev_mon;
-static guint udev_watch = 0;
-
static void udev_start(void)
{
GIOChannel *channel;
@@ -534,7 +538,9 @@ static void udev_start(void)
if (channel == NULL)
return;
- udev_watch = g_io_add_watch(channel, G_IO_IN, udev_event, udev_mon);
+ udev_watch = g_io_add_watch(channel,
+ G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+ udev_event, NULL);
g_io_channel_unref(channel);
}