dhcp/systemd: honor timeout
This commit is contained in:
@@ -338,7 +338,7 @@ nm_dhcp_client_set_state (NMDhcpClient *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
daemon_timeout (gpointer user_data)
|
transaction_timeout (gpointer user_data)
|
||||||
{
|
{
|
||||||
NMDhcpClient *self = NM_DHCP_CLIENT (user_data);
|
NMDhcpClient *self = NM_DHCP_CLIENT (user_data);
|
||||||
NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self);
|
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);
|
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
|
void
|
||||||
nm_dhcp_client_watch_child (NMDhcpClient *self, pid_t pid)
|
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);
|
g_return_if_fail (priv->pid == -1);
|
||||||
priv->pid = pid;
|
priv->pid = pid;
|
||||||
|
|
||||||
/* Set up a timeout on the transaction to kill it after the timeout */
|
nm_dhcp_client_start_timeout (self);
|
||||||
g_assert (priv->timeout_id == 0);
|
|
||||||
priv->timeout_id = g_timeout_add_seconds (priv->timeout,
|
|
||||||
daemon_timeout,
|
|
||||||
self);
|
|
||||||
g_return_if_fail (priv->watch_id == 0);
|
g_return_if_fail (priv->watch_id == 0);
|
||||||
priv->watch_id = g_child_watch_add (pid, daemon_watch_cb, self);
|
priv->watch_id = g_child_watch_add (pid, daemon_watch_cb, self);
|
||||||
}
|
}
|
||||||
|
@@ -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_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_watch_child (NMDhcpClient *self, pid_t pid);
|
||||||
|
|
||||||
void nm_dhcp_client_set_state (NMDhcpClient *self,
|
void nm_dhcp_client_set_state (NMDhcpClient *self,
|
||||||
|
@@ -51,7 +51,6 @@ typedef struct {
|
|||||||
struct sd_dhcp6_client *client6;
|
struct sd_dhcp6_client *client6;
|
||||||
char *lease_file;
|
char *lease_file;
|
||||||
|
|
||||||
guint timeout_id;
|
|
||||||
guint request_count;
|
guint request_count;
|
||||||
|
|
||||||
gboolean privacy;
|
gboolean privacy;
|
||||||
@@ -668,6 +667,8 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nm_dhcp_client_start_timeout (client);
|
||||||
|
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
Reference in New Issue
Block a user