summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-05-30 17:14:46 -0500
committerDan Williams <dcbw@redhat.com>2014-07-18 17:03:27 -0500
commitf33b90fd7b99e6f2eb8fae79e2dd3527c8578810 (patch)
tree5043f4733dd2deeec16cf34d65f80ca6da5b7411
parent7125357c5cde5b06f951cebd20ec5724641da309 (diff)
downloadNetworkManager-f33b90fd7b99e6f2eb8fae79e2dd3527c8578810.tar.gz
dhcp: always signal state changes
Modify code so that listeners remove state change signal handlers before stopping the client. Which means we can remove the 'emit_state' argument from nm_dhcp_client_set_state().
-rw-r--r--src/dhcp-manager/nm-dhcp-client.c13
-rw-r--r--src/dhcp-manager/nm-dhcp-client.h1
-rw-r--r--src/dhcp-manager/nm-dhcp-manager.c4
3 files changed, 8 insertions, 10 deletions
diff --git a/src/dhcp-manager/nm-dhcp-client.c b/src/dhcp-manager/nm-dhcp-client.c
index 495985222a..687c4b0c75 100644
--- a/src/dhcp-manager/nm-dhcp-client.c
+++ b/src/dhcp-manager/nm-dhcp-client.c
@@ -186,15 +186,12 @@ signal_remove (gpointer user_data)
void
nm_dhcp_client_set_state (NMDHCPClient *self,
NMDhcpState state,
- gboolean emit_state,
gboolean remove_now)
{
NMDHCPClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self);
priv->state = state;
-
- if (emit_state)
- g_signal_emit (G_OBJECT (self), signals[SIGNAL_STATE_CHANGED], 0, priv->state);
+ g_signal_emit (G_OBJECT (self), signals[SIGNAL_STATE_CHANGED], 0, priv->state);
if (state == NM_DHCP_STATE_DONE || state == NM_DHCP_STATE_FAIL) {
/* Start the remove signal timer */
@@ -218,7 +215,7 @@ daemon_timeout (gpointer user_data)
"(%s): DHCPv%c request timed out.",
priv->iface,
priv->ipv6 ? '6' : '4');
- nm_dhcp_client_set_state (self, NM_DHCP_STATE_TIMEOUT, TRUE, FALSE);
+ nm_dhcp_client_set_state (self, NM_DHCP_STATE_TIMEOUT, FALSE);
return G_SOURCE_REMOVE;
}
@@ -249,7 +246,7 @@ daemon_watch_cb (GPid pid, gint status, gpointer user_data)
timeout_cleanup (self);
priv->pid = -1;
- nm_dhcp_client_set_state (self, new_state, TRUE, FALSE);
+ nm_dhcp_client_set_state (self, new_state, FALSE);
}
void
@@ -516,7 +513,7 @@ nm_dhcp_client_stop (NMDHCPClient *self, gboolean release)
g_assert (priv->pid == -1);
/* And clean stuff up */
- nm_dhcp_client_set_state (self, NM_DHCP_STATE_DONE, FALSE, TRUE);
+ nm_dhcp_client_set_state (self, NM_DHCP_STATE_DONE, TRUE);
g_hash_table_remove_all (priv->options);
timeout_cleanup (self);
@@ -660,7 +657,7 @@ nm_dhcp_client_new_options (NMDHCPClient *self,
state_to_string (old_state),
state_to_string (new_state));
- nm_dhcp_client_set_state (self, new_state, TRUE, FALSE);
+ nm_dhcp_client_set_state (self, new_state, FALSE);
}
#define NEW_TAG "new_"
diff --git a/src/dhcp-manager/nm-dhcp-client.h b/src/dhcp-manager/nm-dhcp-client.h
index 92e1f3e4b7..b5982e4800 100644
--- a/src/dhcp-manager/nm-dhcp-client.h
+++ b/src/dhcp-manager/nm-dhcp-client.h
@@ -140,7 +140,6 @@ void nm_dhcp_client_watch_child (NMDHCPClient *self, pid_t pid);
void nm_dhcp_client_set_state (NMDHCPClient *self,
NMDhcpState state,
- gboolean emit_state,
gboolean remove_now);
#endif /* NM_DHCP_CLIENT_H */
diff --git a/src/dhcp-manager/nm-dhcp-manager.c b/src/dhcp-manager/nm-dhcp-manager.c
index 1cc9d92901..4345bdc355 100644
--- a/src/dhcp-manager/nm-dhcp-manager.c
+++ b/src/dhcp-manager/nm-dhcp-manager.c
@@ -403,8 +403,10 @@ client_start (NMDHCPManager *self,
/* Kill any old client instance */
client = get_client_for_iface (self, iface, ipv6);
if (client) {
- nm_dhcp_client_stop (client, FALSE);
+ g_object_ref (client);
remove_client (self, client);
+ nm_dhcp_client_stop (client, FALSE);
+ g_object_unref (client);
}
/* And make a new one */