Fix issue with udev versus /dev/rfkill event processing
authorMarcel Holtmann <marcel@holtmann.org>
Mon, 14 Sep 2009 01:33:01 +0000 (18:33 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Mon, 14 Sep 2009 01:33:01 +0000 (18:33 -0700)
src/connman.h
src/element.c
src/udev.c

index ff4e286..5eee390 100644 (file)
@@ -237,6 +237,7 @@ void __connman_udev_cleanup(void);
 char *__connman_udev_get_devtype(const char *ifname);
 char *__connman_udev_get_mbm_devnode(const char *ifname);
 void __connman_udev_rfkill(const char *sysname, connman_bool_t blocked);
+void __connman_udev_enable_rfkill_processing(void);
 
 #include <connman/device.h>
 
index 9a4ba2d..e967491 100644 (file)
@@ -1595,7 +1595,9 @@ void __connman_element_start(void)
 
        __connman_connection_init();
        __connman_ipv4_init();
-       __connman_rfkill_init();
+
+       if (__connman_rfkill_init() < 0)
+               __connman_udev_enable_rfkill_processing();
 }
 
 void __connman_element_stop(void)
@@ -1603,6 +1605,7 @@ void __connman_element_stop(void)
        DBG("");
 
        __connman_rfkill_cleanup();
+
        __connman_ipv4_cleanup();
        __connman_connection_cleanup();
 }
index f65f1f5..f4b9255 100644 (file)
@@ -50,6 +50,8 @@ static int udev_monitor_filter_remove(struct udev_monitor *udev_monitor)
 }
 #endif
 
+static gboolean rfkill_processing = FALSE;
+
 static GSList *device_list = NULL;
 
 static struct connman_device *find_device(int index)
@@ -195,6 +197,9 @@ static void change_rfkill_device(struct udev_device *device)
        const char *value, *type = NULL;
        int state = -1;
 
+       if (rfkill_processing == FALSE)
+               return;
+
        entry = udev_device_get_properties_list_entry(device);
        while (entry) {
                const char *name = udev_list_entry_get_name(entry);
@@ -379,6 +384,13 @@ static struct udev *udev_ctx;
 static struct udev_monitor *udev_mon;
 static guint udev_watch = 0;
 
+void __connman_udev_enable_rfkill_processing(void)
+{
+       rfkill_processing = TRUE;
+
+       enumerate_devices(udev_ctx);
+}
+
 char *__connman_udev_get_devtype(const char *ifname)
 {
        struct udev_device *device;