[PATCH v0.7 2/6] core: allow device subclasses to override DHCP timeout
- From: Daniel Drake <dsd laptop org>
- To: dcbw redhat com
- Cc: networkmanager-list gnome org
- Subject: [PATCH v0.7 2/6] core: allow device subclasses to override DHCP timeout
- Date: Fri, 18 Sep 2009 19:13:31 +0100 (BST)
---
src/dhcp-manager/nm-dhcp-manager.c | 12 ++++++------
src/nm-device.c | 13 ++++++++++++-
src/nm-device.h | 2 ++
3 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/src/dhcp-manager/nm-dhcp-manager.c b/src/dhcp-manager/nm-dhcp-manager.c
index faef79b..c5a6509 100644
--- a/src/dhcp-manager/nm-dhcp-manager.c
+++ b/src/dhcp-manager/nm-dhcp-manager.c
@@ -499,8 +499,7 @@ nm_dhcp_manager_handle_timeout (gpointer user_data)
{
NMDHCPDevice *device = (NMDHCPDevice *) user_data;
- nm_info ("Device '%s' DHCP transaction took too long (>%ds), stopping it.",
- device->iface, NM_DHCP_TIMEOUT);
+ nm_info ("(%s): DHCP transaction took too long, stopping it.", device->iface);
nm_dhcp_manager_cancel_transaction (device->manager, device->iface);
@@ -598,15 +597,16 @@ nm_dhcp_manager_begin_transaction (NMDHCPManager *manager,
nm_dhcp_manager_cancel_transaction_real (device);
}
- nm_info ("Activation (%s) Beginning DHCP transaction.", iface);
+ if (timeout == 0)
+ timeout = NM_DHCP_TIMEOUT;
+
+ nm_info ("Activation (%s) Beginning DHCP transaction (timeout in %d seconds)",
+ iface, timeout);
device->pid = nm_dhcp_client_start (device, uuid, s_ip4);
if (device->pid == 0)
return FALSE;
- if (timeout == 0)
- timeout = NM_DHCP_TIMEOUT;
-
/* Set up a timeout on the transaction to kill it after the timeout */
device->timeout_id = g_timeout_add_seconds (timeout,
nm_dhcp_manager_handle_timeout,
diff --git a/src/nm-device.c b/src/nm-device.c
index 1506b96..c55a9e5 100644
--- a/src/nm-device.c
+++ b/src/nm-device.c
@@ -91,6 +91,7 @@ struct _NMDevicePrivate
/* IP configuration info */
NMIP4Config * ip4_config; /* Config from DHCP, PPP, or system config files */
NMDHCPManager * dhcp_manager;
+ guint32 dhcp_timeout;
gulong dhcp_state_sigid;
gulong dhcp_timeout_sigid;
NMDHCP4Config * dhcp4_config;
@@ -142,6 +143,7 @@ nm_device_init (NMDevice * self)
self->priv->capabilities = NM_DEVICE_CAP_NONE;
memset (&self->priv->ip6_address, 0, sizeof (struct in6_addr));
self->priv->state = NM_DEVICE_STATE_UNMANAGED;
+ self->priv->dhcp_timeout = 0;
}
static gboolean
@@ -896,7 +898,7 @@ real_act_stage3_ip_config_start (NMDevice *self, NMDeviceStateReason *reason)
/* DHCP manager will cancel any transaction already in progress and we do not
want to cancel this activation if we get "down" state from that. */
g_signal_handler_block (priv->dhcp_manager, priv->dhcp_state_sigid);
- success = nm_dhcp_manager_begin_transaction (priv->dhcp_manager, ip_iface, uuid, s_ip4, 45);
+ success = nm_dhcp_manager_begin_transaction (priv->dhcp_manager, ip_iface, uuid, s_ip4, priv->dhcp_timeout);
g_signal_handler_unblock (priv->dhcp_manager, priv->dhcp_state_sigid);
if (success) {
@@ -2511,3 +2513,12 @@ nm_device_set_managed (NMDevice *device,
nm_device_state_changed (device, NM_DEVICE_STATE_UNMANAGED, reason);
}
+void
+nm_device_set_dhcp_timeout (NMDevice *device,
+ guint32 timeout)
+{
+ g_return_if_fail (NM_IS_DEVICE (device));
+
+ NM_DEVICE_GET_PRIVATE (device)->dhcp_timeout = timeout;
+}
+
diff --git a/src/nm-device.h b/src/nm-device.h
index f78e1e8..fc394dd 100644
--- a/src/nm-device.h
+++ b/src/nm-device.h
@@ -165,6 +165,8 @@ void nm_device_set_managed (NMDevice *device,
gboolean managed,
NMDeviceStateReason reason);
+void nm_device_set_dhcp_timeout (NMDevice *device, guint32 timeout);
+
G_END_DECLS
#endif /* NM_DEVICE_H */
--
1.6.4
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]