diff options
author | Thomas Haller <thaller@redhat.com> | 2015-01-05 19:30:00 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-01-08 15:46:21 +0100 |
commit | 7de3e176caa03c0f2099cd10361583f7fb70cb49 (patch) | |
tree | 8b4b2f57deac1065d7c469f876c7998baf169d36 | |
parent | 439bbacc37fc347401d2fdd4545a56fb05a22f1e (diff) | |
download | NetworkManager-7de3e176caa03c0f2099cd10361583f7fb70cb49.tar.gz |
core: declare nm_dhcp_manager_get() using NM_DEFINE_SINGLETON_GETTER()
-rw-r--r-- | src/dhcp-manager/nm-dhcp-manager.c | 11 | ||||
-rw-r--r-- | src/main.c | 5 | ||||
-rw-r--r-- | src/nm-iface-helper.c | 7 |
3 files changed, 2 insertions, 21 deletions
diff --git a/src/dhcp-manager/nm-dhcp-manager.c b/src/dhcp-manager/nm-dhcp-manager.c index f936f45c58..c547af10cd 100644 --- a/src/dhcp-manager/nm-dhcp-manager.c +++ b/src/dhcp-manager/nm-dhcp-manager.c @@ -371,16 +371,7 @@ nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self, /***************************************************/ -NMDhcpManager * -nm_dhcp_manager_get (void) -{ - static NMDhcpManager *singleton = NULL; - - if (G_UNLIKELY (singleton == NULL)) - singleton = g_object_new (NM_TYPE_DHCP_MANAGER, NULL); - g_assert (singleton); - return singleton; -} +NM_DEFINE_SINGLETON_GETTER (NMDhcpManager, nm_dhcp_manager_get, NM_TYPE_DHCP_MANAGER); static void nm_dhcp_manager_init (NMDhcpManager *self) diff --git a/src/main.c b/src/main.c index 5f80bcd1b3..ba1de09a7b 100644 --- a/src/main.c +++ b/src/main.c @@ -205,7 +205,6 @@ main (int argc, char *argv[]) gs_unref_object NMVpnManager *vpn_manager = NULL; gs_unref_object NMDBusManager *dbus_mgr = NULL; gs_unref_object NMSupplicantManager *sup_mgr = NULL; - gs_unref_object NMDhcpManager *dhcp_mgr = NULL; gs_unref_object NMFirewallManager *fw_mgr = NULL; gs_unref_object NMSettings *settings = NULL; gs_unref_object NMConfig *config = NULL; @@ -400,10 +399,6 @@ main (int argc, char *argv[]) vpn_manager = nm_vpn_manager_get (); g_assert (vpn_manager != NULL); - /* Initialize DHCP manager */ - dhcp_mgr = nm_dhcp_manager_get (); - g_assert (dhcp_mgr != NULL); - nm_dispatcher_init (); settings = nm_settings_new (&error); diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c index 9d5cdc05cf..910c804711 100644 --- a/src/nm-iface-helper.c +++ b/src/nm-iface-helper.c @@ -277,7 +277,6 @@ main (int argc, char *argv[]) gboolean show_version = FALSE, slaac = FALSE; char *bad_domains = NULL, *dhcp4_hostname = NULL, *uuid = NULL; char *iid_str = NULL, *dhcp4_clientid = NULL, *dhcp4_address = NULL; - gs_unref_object NMDhcpManager *dhcp_mgr = NULL; GError *error = NULL; gboolean wrote_pidfile = FALSE; gs_free char *pidfile = NULL; @@ -430,11 +429,7 @@ main (int argc, char *argv[]) if (dhcp4_address) { nm_platform_sysctl_set (nm_utils_ip4_property_path (ifname, "promote_secondaries"), "1"); - /* Initialize DHCP manager */ - dhcp_mgr = nm_dhcp_manager_get (); - g_assert (dhcp_mgr != NULL); - - dhcp4_client = nm_dhcp_manager_start_ip4 (dhcp_mgr, + dhcp4_client = nm_dhcp_manager_start_ip4 (nm_dhcp_manager_get (), ifname, ifindex, hwaddr, |