From 29ff3552e43a2fe58a1e49ca469ff50932146509 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sat, 29 Aug 2009 22:28:32 -0700 Subject: [PATCH] Remove all the useless D-Bus connection passing --- src/agent.c | 11 +++++++---- src/connman.h | 9 ++++----- src/element.c | 10 ++++++---- src/main.c | 8 ++++---- src/manager.c | 11 +++++++---- src/profile.c | 8 ++++---- 6 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/agent.c b/src/agent.c index 5ae62b2..42a126e 100644 --- a/src/agent.c +++ b/src/agent.c @@ -85,11 +85,11 @@ int __connman_agent_unregister(const char *sender, const char *path) return 0; } -int __connman_agent_init(DBusConnection *conn) +int __connman_agent_init(void) { - DBG("conn %p", conn); + DBG(""); - connection = dbus_connection_ref(conn); + connection = connman_dbus_get_connection(); if (connection == NULL) return -1; @@ -100,7 +100,10 @@ void __connman_agent_cleanup(void) { DBusMessage *msg; - DBG("conn %p", connection); + DBG(""); + + if (connection == NULL) + return; if (agent_watch > 0) g_dbus_remove_watch(connection, agent_watch); diff --git a/src/connman.h b/src/connman.h index 8392201..af11c29 100644 --- a/src/connman.h +++ b/src/connman.h @@ -55,10 +55,10 @@ int __connman_selftest(void); #include -int __connman_manager_init(DBusConnection *conn, gboolean compat); +int __connman_manager_init(gboolean compat); void __connman_manager_cleanup(void); -int __connman_agent_init(DBusConnection *conn); +int __connman_agent_init(void); void __connman_agent_cleanup(void); int __connman_agent_register(const char *sender, const char *path); @@ -170,8 +170,7 @@ void __connman_driver_rescan(struct connman_driver *driver); #include -int __connman_element_init(DBusConnection *conn, const char *device, - const char *nodevice); +int __connman_element_init(const char *device, const char *nodevice); void __connman_element_start(void); void __connman_element_stop(void); void __connman_element_cleanup(void); @@ -286,7 +285,7 @@ connman_bool_t __connman_network_get_weakness(struct connman_network *network); #include -int __connman_profile_init(DBusConnection *conn); +int __connman_profile_init(); void __connman_profile_cleanup(void); connman_bool_t __connman_profile_get_offlinemode(void); diff --git a/src/element.c b/src/element.c index 3b77494..9a4ba2d 100644 --- a/src/element.c +++ b/src/element.c @@ -1535,14 +1535,13 @@ void connman_element_set_error(struct connman_element *element, __connman_service_indicate_error(service, convert_error(error)); } -int __connman_element_init(DBusConnection *conn, const char *device, - const char *nodevice) +int __connman_element_init(const char *device, const char *nodevice) { struct connman_element *element; - DBG("conn %p", conn); + DBG(""); - connection = dbus_connection_ref(conn); + connection = connman_dbus_get_connection(); if (connection == NULL) return -EIO; @@ -1658,5 +1657,8 @@ void __connman_element_cleanup(void) g_free(device_filter); + if (connection == NULL) + return; + dbus_connection_unref(connection); } diff --git a/src/main.c b/src/main.c index 9742125..ef9b017 100644 --- a/src/main.c +++ b/src/main.c @@ -201,11 +201,11 @@ int main(int argc, char *argv[]) __connman_dbus_init(conn); __connman_storage_init(); - __connman_element_init(conn, option_device, option_nodevice); + __connman_element_init(option_device, option_nodevice); - __connman_agent_init(conn); - __connman_manager_init(conn, option_compat); - __connman_profile_init(conn); + __connman_agent_init(); + __connman_manager_init(option_compat); + __connman_profile_init(); __connman_resolver_init(); __connman_ipconfig_init(); diff --git a/src/manager.c b/src/manager.c index 30a24e8..8acb317 100644 --- a/src/manager.c +++ b/src/manager.c @@ -720,11 +720,11 @@ static GDBusMethodTable nm_methods[] = { static gboolean nm_compat = FALSE; -int __connman_manager_init(DBusConnection *conn, gboolean compat) +int __connman_manager_init(gboolean compat) { - DBG("conn %p", conn); + DBG(""); - connection = dbus_connection_ref(conn); + connection = connman_dbus_get_connection(); if (connection == NULL) return -1; @@ -748,10 +748,13 @@ int __connman_manager_init(DBusConnection *conn, gboolean compat) void __connman_manager_cleanup(void) { - DBG("conn %p", connection); + DBG(""); connman_notifier_unregister(&technology_notifier); + if (connection == NULL) + return; + if (nm_compat == TRUE) { g_dbus_unregister_interface(connection, NM_PATH, NM_INTERFACE); } diff --git a/src/profile.c b/src/profile.c index edddd20..0b2a411 100644 --- a/src/profile.c +++ b/src/profile.c @@ -685,11 +685,11 @@ static struct connman_storage profile_storage = { .profile_save = profile_save, }; -int __connman_profile_init(DBusConnection *conn) +int __connman_profile_init(void) { - DBG("conn %p", conn); + DBG(""); - connection = dbus_connection_ref(conn); + connection = connman_dbus_get_connection(); if (connection == NULL) return -1; @@ -704,7 +704,7 @@ int __connman_profile_init(DBusConnection *conn) void __connman_profile_cleanup(void) { - DBG("conn %p", connection); + DBG(""); if (profiles != NULL) { g_hash_table_destroy(profiles); -- 2.7.4