summaryrefslogtreecommitdiffstats
path: root/plugins/udev.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2011-07-29 14:08:28 +0200
committerMarcel Holtmann <marcel@holtmann.org>2011-07-29 14:08:28 +0200
commita5be01c0c843fd849e683d1d2bde739327e23f11 (patch)
tree006c48a273ba59ebd51d36ade262bd42bfa2481a /plugins/udev.c
parenta69690b3b5b86f11165efd9df10827f1b922a0ed (diff)
downloadofono-a5be01c0c843fd849e683d1d2bde739327e23f11.tar.bz2
udev: Report problems with the udev monitor channel
Diffstat (limited to 'plugins/udev.c')
-rw-r--r--plugins/udev.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/plugins/udev.c b/plugins/udev.c
index 90d0aad8..abd08614 100644
--- a/plugins/udev.c
+++ b/plugins/udev.c
@@ -901,14 +901,23 @@ static void enumerate_devices(struct udev *context)
udev_enumerate_unref(enumerate);
}
-static gboolean udev_event(GIOChannel *channel,
- GIOCondition condition, gpointer user_data)
+static struct udev *udev_ctx;
+static struct udev_monitor *udev_mon;
+static guint udev_watch = 0;
+
+static gboolean udev_event(GIOChannel *channel, GIOCondition cond,
+ gpointer user_data)
{
- struct udev_monitor *monitor = user_data;
struct udev_device *device;
const char *subsystem, *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;
@@ -938,10 +947,6 @@ done:
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;
@@ -960,7 +965,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);
}