NetworkManager r4037 - in trunk: . src
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r4037 - in trunk: . src
- Date: Fri, 5 Sep 2008 02:55:41 +0000 (UTC)
Author: dcbw
Date: Fri Sep 5 02:55:40 2008
New Revision: 4037
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=4037&view=rev
Log:
2008-09-04 Dan Williams <dcbw redhat com>
* src/nm-ip4-config.c
src/nm-ip4-config.h
- (nm_ip4_config_new): don't export over D-Bus here
- (nm_ip4_config_export): new function; export the config over D-Bus
- (nm_ip4_config_is_exported): new function
* src/nm-device.c
- (nm_device_activate_stage5_ip_config_commit): fix leak of IP4Config
objects by balancing the IP4Config constructor; the device holds
a reference to the IP4Config already
- (nm_device_set_ip4_config): export the IP4Config when needed
Modified:
trunk/ChangeLog
trunk/src/nm-device.c
trunk/src/nm-ip4-config.c
trunk/src/nm-ip4-config.h
Modified: trunk/src/nm-device.c
==============================================================================
--- trunk/src/nm-device.c (original)
+++ trunk/src/nm-device.c Fri Sep 5 02:55:40 2008
@@ -1392,6 +1392,10 @@
out:
nm_info ("Activation (%s) Stage 5 of 5 (IP Configure Commit) complete.",
iface);
+
+ /* Balance IP4Config creation; device takes ownership in set_ip4_config() */
+ g_object_unref (ip4_config);
+
return FALSE;
}
@@ -1889,6 +1893,10 @@
priv->ip4_config = g_object_ref (config);
+ /* Export over D-Bus if needed */
+ if (!nm_ip4_config_is_exported (config))
+ nm_ip4_config_export (config);
+
success = nm_system_device_set_from_ip4_config (ip_iface, config);
if (success)
nm_device_update_ip4_address (self);
Modified: trunk/src/nm-ip4-config.c
==============================================================================
--- trunk/src/nm-ip4-config.c (original)
+++ trunk/src/nm-ip4-config.c Fri Sep 5 02:55:40 2008
@@ -45,6 +45,8 @@
#define NM_IP4_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IP4_CONFIG, NMIP4ConfigPrivate))
typedef struct {
+ char *path;
+
GSList *addresses;
guint32 ptp_address;
@@ -75,20 +77,39 @@
NMIP4Config *
nm_ip4_config_new (void)
{
- GObject *object;
+ return (NMIP4Config *) g_object_new (NM_TYPE_IP4_CONFIG, NULL);
+}
+
+void
+nm_ip4_config_export (NMIP4Config *config)
+{
+ NMIP4ConfigPrivate *priv;
+ NMDBusManager *dbus_mgr;
DBusGConnection *connection;
- char *path;
static guint32 counter = 0;
- object = g_object_new (NM_TYPE_IP4_CONFIG, NULL);
+ g_return_if_fail (NM_IS_IP4_CONFIG (config));
- connection = nm_dbus_manager_get_connection (nm_dbus_manager_get ());
- path = g_strdup_printf (NM_DBUS_PATH "/IP4Config/%d", counter++);
+ priv = NM_IP4_CONFIG_GET_PRIVATE (config);
+ g_return_if_fail (priv->path == NULL);
+
+ dbus_mgr = nm_dbus_manager_get ();
+ connection = nm_dbus_manager_get_connection (dbus_mgr);
+ priv->path = g_strdup_printf (NM_DBUS_PATH "/IP4Config/%d", counter++);
+
+ dbus_g_connection_register_g_object (connection, priv->path, G_OBJECT (config));
+ g_object_unref (dbus_mgr);
+}
- dbus_g_connection_register_g_object (connection, path, object);
- g_free (path);
+gboolean
+nm_ip4_config_is_exported (NMIP4Config *config)
+{
+ NMIP4ConfigPrivate *priv;
- return (NMIP4Config *) object;
+ g_return_val_if_fail (NM_IS_IP4_CONFIG (config), FALSE);
+
+ priv = NM_IP4_CONFIG_GET_PRIVATE (config);
+ return !!priv->path;
}
void
Modified: trunk/src/nm-ip4-config.h
==============================================================================
--- trunk/src/nm-ip4-config.h (original)
+++ trunk/src/nm-ip4-config.h Fri Sep 5 02:55:40 2008
@@ -55,8 +55,9 @@
GType nm_ip4_config_get_type (void);
-NMIP4Config * nm_ip4_config_new (void);
-NMIP4Config * nm_ip4_config_copy (NMIP4Config *config);
+NMIP4Config * nm_ip4_config_new (void);
+void nm_ip4_config_export (NMIP4Config *config);
+gboolean nm_ip4_config_is_exported (NMIP4Config *config);
void nm_ip4_config_take_address (NMIP4Config *config, NMSettingIP4Address *address);
void nm_ip4_config_add_address (NMIP4Config *config, NMSettingIP4Address *address);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]