From: Marcel Holtmann Date: Wed, 24 Dec 2008 08:20:30 +0000 (+0100) Subject: Postpone initial driver probing after all plugins are loaded X-Git-Tag: accepted/2.0alpha-wayland/20121110.002834~4355 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b02bc47fd3c6e55a529f11f7209b56d34ce4ce33;p=profile%2Fivi%2Fconnman.git Postpone initial driver probing after all plugins are loaded --- diff --git a/src/connman.h b/src/connman.h index 70fcac1..3c2f699 100644 --- a/src/connman.h +++ b/src/connman.h @@ -83,6 +83,7 @@ void __connman_driver_rescan(struct connman_driver *driver); #include int __connman_element_init(DBusConnection *conn, const char *device); +void __connman_element_start(void); void __connman_element_cleanup(void); void __connman_element_list(struct connman_element *element, diff --git a/src/element.c b/src/element.c index 0352646..ea4bea4 100644 --- a/src/element.c +++ b/src/element.c @@ -38,6 +38,8 @@ static GNode *element_root = NULL; static GSList *driver_list = NULL; static gchar *device_filter = NULL; +static gboolean started = FALSE; + static struct { enum connman_property_id id; int type; @@ -1053,6 +1055,9 @@ int connman_driver_register(struct connman_driver *driver) driver_list = g_slist_insert_sorted(driver_list, driver, compare_priority); + if (started == FALSE) + return 0; + if (element_root != NULL) g_node_traverse(element_root, G_PRE_ORDER, G_TRAVERSE_ALL, -1, probe_driver, driver); @@ -1894,11 +1899,35 @@ static void set_signal_strength(struct connman_element *connection) } } +static void probe_element(struct connman_element *element) +{ + GSList *list; + + DBG("element %p name %s", element, element->name); + + for (list = driver_list; list; list = list->next) { + struct connman_driver *driver = list->data; + + if (match_driver(element, driver) == FALSE) + continue; + + DBG("driver %p name %s", driver, driver->name); + + if (driver->probe(element) == 0) { + __connman_element_lock(element); + element->driver = driver; + __connman_element_unlock(element); + + enable_element(element); + break; + } + } +} + static void register_element(gpointer data, gpointer user_data) { struct connman_element *element = data; const gchar *basepath; - GSList *list; GNode *node; __connman_element_lock(element); @@ -1968,23 +1997,10 @@ static void register_element(gpointer data, gpointer user_data) __connman_element_store(element); - for (list = driver_list; list; list = list->next) { - struct connman_driver *driver = list->data; - - if (match_driver(element, driver) == FALSE) - continue; - - DBG("driver %p name %s", driver, driver->name); - - if (driver->probe(element) == 0) { - __connman_element_lock(element); - element->driver = driver; - __connman_element_unlock(element); + if (started == FALSE) + return; - enable_element(element); - break; - } - } + probe_element(element); } /** @@ -2206,6 +2222,33 @@ int __connman_element_init(DBusConnection *conn, const char *device) return 0; } +static gboolean probe_node(GNode *node, gpointer data) +{ + struct connman_element *element = node->data; + + DBG("element %p name %s", element, element->name); + + if (element->type == CONNMAN_ELEMENT_TYPE_ROOT) + return FALSE; + + if (element->driver) + return FALSE; + + probe_element(element); + + return FALSE; +} + +void __connman_element_start(void) +{ + DBG(""); + + g_node_traverse(element_root, G_PRE_ORDER, G_TRAVERSE_ALL, -1, + probe_node, NULL); + + started = TRUE; +} + static gboolean free_driver(GNode *node, gpointer data) { struct connman_element *element = node->data; diff --git a/src/main.c b/src/main.c index 638ad0b..357decb 100644 --- a/src/main.c +++ b/src/main.c @@ -166,6 +166,8 @@ int main(int argc, char *argv[]) __connman_plugin_init(); + __connman_element_start(); + g_free(option_device); memset(&sa, 0, sizeof(sa));