diff --git a/src/dhcp-manager/nm-dhcp-client.c b/src/dhcp-manager/nm-dhcp-client.c index 862bde7a04..2c210becdb 100644 --- a/src/dhcp-manager/nm-dhcp-client.c +++ b/src/dhcp-manager/nm-dhcp-client.c @@ -338,7 +338,7 @@ nm_dhcp_client_set_state (NMDhcpClient *self, } static gboolean -daemon_timeout (gpointer user_data) +transaction_timeout (gpointer user_data) { NMDhcpClient *self = NM_DHCP_CLIENT (user_data); NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); @@ -392,6 +392,18 @@ daemon_watch_cb (GPid pid, gint status, gpointer user_data) nm_dhcp_client_set_state (self, new_state, NULL, NULL); } +void +nm_dhcp_client_start_timeout (NMDhcpClient *self) +{ + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); + + /* Set up a timeout on the transaction to kill it after the timeout */ + g_assert (priv->timeout_id == 0); + priv->timeout_id = g_timeout_add_seconds (priv->timeout, + transaction_timeout, + self); +} + void nm_dhcp_client_watch_child (NMDhcpClient *self, pid_t pid) { @@ -400,11 +412,8 @@ nm_dhcp_client_watch_child (NMDhcpClient *self, pid_t pid) g_return_if_fail (priv->pid == -1); priv->pid = pid; - /* Set up a timeout on the transaction to kill it after the timeout */ - g_assert (priv->timeout_id == 0); - priv->timeout_id = g_timeout_add_seconds (priv->timeout, - daemon_timeout, - self); + nm_dhcp_client_start_timeout (self); + g_return_if_fail (priv->watch_id == 0); priv->watch_id = g_child_watch_add (pid, daemon_watch_cb, self); } diff --git a/src/dhcp-manager/nm-dhcp-client.h b/src/dhcp-manager/nm-dhcp-client.h index 7e28391d16..1c78c5b124 100644 --- a/src/dhcp-manager/nm-dhcp-client.h +++ b/src/dhcp-manager/nm-dhcp-client.h @@ -154,6 +154,8 @@ void nm_dhcp_client_stop_existing (const char *pid_file, const char *binary_name void nm_dhcp_client_stop_pid (pid_t pid, const char *iface); +void nm_dhcp_client_start_timeout (NMDhcpClient *self); + void nm_dhcp_client_watch_child (NMDhcpClient *self, pid_t pid); void nm_dhcp_client_set_state (NMDhcpClient *self, diff --git a/src/dhcp-manager/nm-dhcp-systemd.c b/src/dhcp-manager/nm-dhcp-systemd.c index bafc7c9d3b..ca4027e8dd 100644 --- a/src/dhcp-manager/nm-dhcp-systemd.c +++ b/src/dhcp-manager/nm-dhcp-systemd.c @@ -51,7 +51,6 @@ typedef struct { struct sd_dhcp6_client *client6; char *lease_file; - guint timeout_id; guint request_count; gboolean privacy; @@ -668,6 +667,8 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last goto error; } + nm_dhcp_client_start_timeout (client); + success = TRUE; error: