From 4e0af0aa52922090058f2f92acc277a2bf4e072f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 4 May 2015 16:54:51 +0200 Subject: [PATCH] platform: move nm_platform_query_devices() to nm-manager nm_platform_query_devices() would raise an 'added' signal for all its links. That is bad style because it could confuse other listeners for platform signals which don't expect such artificial change signals. The public API of NMPlatform already gives NMManager the ability to 'pull' all the links and iterate them itself. Before, nm_platform_query_devices() would also initialize udev devices, so there was a more compelling reason for this function. (cherry picked from commit d7a312d17a09b748d5aa06d7dfbebc66f0e8cf68) --- src/nm-manager.c | 17 ++++++++++++++++- src/platform/nm-platform.c | 26 -------------------------- src/platform/nm-platform.h | 2 -- 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index 4950c98f86..0c1201cee2 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -1977,6 +1977,21 @@ platform_link_cb (NMPlatform *platform, } } +static void +platform_query_devices (NMManager *self) +{ + GArray *links_array; + NMPlatformLink *links; + int i; + + links_array = nm_platform_link_get_all (NM_PLATFORM_GET); + links = (NMPlatformLink *) links_array->data; + for (i = 0; i < links_array->len; i++) + platform_link_added (self, links[i].ifindex, &links[i], NM_PLATFORM_REASON_INTERNAL); + + g_array_unref (links_array); +} + static void rfkill_manager_rfkill_changed_cb (NMRfkillManager *rfkill_mgr, RfKillType rtype, @@ -4113,7 +4128,7 @@ nm_manager_start (NMManager *self) /* Start device factories */ nm_device_factory_manager_for_each_factory (start_factory, NULL); - nm_platform_query_devices (NM_PLATFORM_GET); + platform_query_devices (self); /* * Connections added before the manager is started do not emit diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 97e0295fc2..79e83b6aef 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -383,32 +383,6 @@ nm_platform_sysctl_get_int_checked (NMPlatform *self, const char *path, guint ba /******************************************************************/ -/** - * nm_platform_query_devices: - * self: platform instance - * - * Emit #NMPlatform:link-changed ADDED signals for all currently-known links. - * Should only be called at startup. - */ -void -nm_platform_query_devices (NMPlatform *self) -{ - GArray *links_array; - NMPlatformLink *links; - int i; - - _CHECK_SELF_VOID (self, klass); - - links_array = nm_platform_link_get_all (self); - links = (NMPlatformLink *) links_array->data; - for (i = 0; i < links_array->len; i++) { - g_signal_emit (self, signals[SIGNAL_LINK_CHANGED], 0, - links[i].ifindex, &links[i], NM_PLATFORM_SIGNAL_ADDED, - NM_PLATFORM_REASON_INTERNAL); - } - g_array_unref (links_array); -} - /** * nm_platform_link_get_all: * self: platform instance diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index e9184a0148..5b42968733 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -532,8 +532,6 @@ void nm_platform_set_error (NMPlatform *self, NMPlatformError error); NMPlatformError nm_platform_get_error (NMPlatform *self); const char *nm_platform_get_error_msg (NMPlatform *self); -void nm_platform_query_devices (NMPlatform *self); - gboolean nm_platform_sysctl_set (NMPlatform *self, const char *path, const char *value); char *nm_platform_sysctl_get (NMPlatform *self, const char *path); gint32 nm_platform_sysctl_get_int32 (NMPlatform *self, const char *path, gint32 fallback);