summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2016-01-25 09:46:58 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2016-01-25 15:22:15 +0100
commit7aff24478a13cc074f483f2c42788b0ed0187d68 (patch)
tree7cb2aea9d465c9c8f4220a700c8b097d9eae7e2e
parent5b5a3512d2b5eab84bd6f6db68cd265e3a5b0857 (diff)
downloadNetworkManager-7aff24478a13cc074f483f2c42788b0ed0187d68.tar.gz
dhcp/systemd: honor timeout
-rw-r--r--src/dhcp-manager/nm-dhcp-client.c21
-rw-r--r--src/dhcp-manager/nm-dhcp-client.h2
-rw-r--r--src/dhcp-manager/nm-dhcp-systemd.c3
3 files changed, 19 insertions, 7 deletions
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);
@@ -393,18 +393,27 @@ daemon_watch_cb (GPid pid, gint status, gpointer user_data)
}
void
-nm_dhcp_client_watch_child (NMDhcpClient *self, pid_t pid)
+nm_dhcp_client_start_timeout (NMDhcpClient *self)
{
NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self);
- 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,
+ transaction_timeout,
self);
+}
+
+void
+nm_dhcp_client_watch_child (NMDhcpClient *self, pid_t pid)
+{
+ NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self);
+
+ g_return_if_fail (priv->pid == -1);
+ priv->pid = pid;
+
+ 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: