From: Marcel Holtmann Date: Thu, 23 Jul 2009 07:14:58 +0000 (+0200) Subject: Fix setup of udev context before loading any plugins X-Git-Tag: 2.0_alpha~3396 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d82622c6ebe810c766a2e731d84130363aa5c4ab;p=framework%2Fconnectivity%2Fconnman.git Fix setup of udev context before loading any plugins --- diff --git a/src/connman.h b/src/connman.h index d23ff63..93d508f 100644 --- a/src/connman.h +++ b/src/connman.h @@ -201,6 +201,7 @@ void __connman_connection_cleanup(void); gboolean __connman_connection_update_gateway(void); int __connman_udev_init(void); +void __connman_udev_start(void); void __connman_udev_cleanup(void); char *__connman_udev_get_devtype(const char *ifname); char *__connman_udev_get_mbm_devnode(const char *ifname); @@ -319,6 +320,7 @@ void __connman_notifier_offlinemode(connman_bool_t enabled); #include int __connman_rtnl_init(void); +void __connman_rtnl_start(void); void __connman_rtnl_cleanup(void); int __connman_rtnl_send(const void *buf, size_t len); diff --git a/src/element.c b/src/element.c index a5af1a7..60fbca1 100644 --- a/src/element.c +++ b/src/element.c @@ -1609,8 +1609,8 @@ void __connman_element_start(void) started = TRUE; - __connman_rtnl_init(); - __connman_udev_init(); + __connman_rtnl_start(); + __connman_udev_start(); __connman_connection_init(); __connman_ipv4_init(); diff --git a/src/main.c b/src/main.c index c35d0d8..ede37a0 100644 --- a/src/main.c +++ b/src/main.c @@ -205,6 +205,8 @@ int main(int argc, char *argv[]) __connman_profile_init(conn); __connman_resolver_init(); + __connman_rtnl_init(); + __connman_udev_init(); __connman_plugin_init(option_plugin, option_noplugin); diff --git a/src/rtnl.c b/src/rtnl.c index 70e8c3c..5b07865 100644 --- a/src/rtnl.c +++ b/src/rtnl.c @@ -759,6 +759,11 @@ int __connman_rtnl_init(void) return 0; } +void __connman_rtnl_start(void) +{ + DBG(""); +} + void __connman_rtnl_cleanup(void) { GSList *list; diff --git a/src/udev-compat.c b/src/udev-compat.c index 448a18f..3ac069b 100644 --- a/src/udev-compat.c +++ b/src/udev-compat.c @@ -127,17 +127,16 @@ void __connman_udev_rfkill(const char *sysname, connman_bool_t blocked) int __connman_udev_init(void) { - int err; - DBG(""); - err = connman_rtnl_register(&detect_rtnl); - if (err < 0) - return err; + return connman_rtnl_register(&detect_rtnl); +} - connman_rtnl_send_getlink(); +void __connman_udev_start(void) +{ + DBG(""); - return 0; + connman_rtnl_send_getlink(); } void __connman_udev_cleanup(void) diff --git a/src/udev.c b/src/udev.c index b14b625..f65f1f5 100644 --- a/src/udev.c +++ b/src/udev.c @@ -35,7 +35,6 @@ #include "connman.h" #ifdef NEED_UDEV_MONITOR_FILTER -#if 0 static int udev_monitor_filter_add_match_subsystem_devtype(struct udev_monitor *udev_monitor, const char *subsystem, const char *devtype) { @@ -50,7 +49,6 @@ static int udev_monitor_filter_remove(struct udev_monitor *udev_monitor) return -EINVAL; } #endif -#endif static GSList *device_list = NULL; @@ -480,9 +478,6 @@ void __connman_udev_rfkill(const char *sysname, connman_bool_t blocked) int __connman_udev_init(void) { - GIOChannel *channel; - int fd; - DBG(""); udev_ctx = udev_new(); @@ -499,12 +494,26 @@ int __connman_udev_init(void) return -1; } + udev_monitor_filter_add_match_subsystem_devtype(udev_mon, + "net", NULL); + udev_monitor_filter_add_match_subsystem_devtype(udev_mon, + "rfkill", NULL); + + udev_monitor_filter_update(udev_mon); + + return 0; +} + +void __connman_udev_start(void) +{ + GIOChannel *channel; + int fd; + + DBG(""); + if (udev_monitor_enable_receiving(udev_mon) < 0) { connman_error("Failed to enable udev monitor"); - udev_unref(udev_ctx); - udev_ctx = NULL; - udev_monitor_unref(udev_mon); - return -1; + return; } enumerate_devices(udev_ctx); @@ -513,13 +522,11 @@ int __connman_udev_init(void) channel = g_io_channel_unix_new(fd); if (channel == NULL) - return 0; + return; udev_watch = g_io_add_watch(channel, G_IO_IN, udev_event, udev_mon); g_io_channel_unref(channel); - - return 0; } void __connman_udev_cleanup(void) @@ -544,6 +551,8 @@ void __connman_udev_cleanup(void) if (udev_ctx == NULL) return; + udev_monitor_filter_remove(udev_mon); + udev_monitor_unref(udev_mon); udev_unref(udev_ctx); }