[PATCH] Use the dhcp timeout option
- From: Sjoerd Simons <sjoerd simons collabora co uk>
- To: networkmanager-list gnome org
- Subject: [PATCH] Use the dhcp timeout option
- Date: Mon, 4 Aug 2008 12:28:39 +0100
Use the dhcp timeout option from the ip4 config options if set. Otherwise use
the default 45 seconds
Signed-off-by: Sjoerd Simons <sjoerd simons collabora co uk>
---
src/dhcp-manager/nm-dhcp-manager.c | 13 ++++++++-----
src/dhcp-manager/nm-dhcp-manager.h | 3 +--
src/nm-device.c | 4 +++-
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/dhcp-manager/nm-dhcp-manager.c b/src/dhcp-manager/nm-dhcp-manager.c
index 4846bf1..b91154a 100644
--- a/src/dhcp-manager/nm-dhcp-manager.c
+++ b/src/dhcp-manager/nm-dhcp-manager.c
@@ -472,8 +472,8 @@ 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 ("Device '%s' DHCP transaction took too long, stopping it.",
+ device->iface);
nm_dhcp_manager_cancel_transaction (device->manager, device->iface);
@@ -552,11 +552,11 @@ static void dhcp_watch_cb (GPid pid, gint status, gpointer user_data)
gboolean
nm_dhcp_manager_begin_transaction (NMDHCPManager *manager,
const char *iface,
- NMSettingIP4Config *s_ip4,
- guint32 timeout)
+ NMSettingIP4Config *s_ip4)
{
NMDHCPManagerPrivate *priv;
NMDHCPDevice *device;
+ guint32 timeout = 0;
g_return_val_if_fail (NM_IS_DHCP_MANAGER (manager), FALSE);
g_return_val_if_fail (iface != NULL, FALSE);
@@ -572,11 +572,14 @@ nm_dhcp_manager_begin_transaction (NMDHCPManager *manager,
nm_dhcp_manager_cancel_transaction_real (device, TRUE);
}
- nm_info ("Activation (%s) Beginning DHCP transaction.", iface);
+ if (s_ip4)
+ timeout = s_ip4->dhcp_timeout;
if (timeout == 0)
timeout = NM_DHCP_TIMEOUT;
+ nm_info ("Activation (%s) Beginning DHCP transaction. (timeout %d seconds)", iface, timeout);
+
/* Set up a timeout on the transaction to kill it after the timeout */
device->timeout_id = g_timeout_add (timeout * 1000,
nm_dhcp_manager_handle_timeout,
diff --git a/src/dhcp-manager/nm-dhcp-manager.h b/src/dhcp-manager/nm-dhcp-manager.h
index 1471479..f32e2e2 100644
--- a/src/dhcp-manager/nm-dhcp-manager.h
+++ b/src/dhcp-manager/nm-dhcp-manager.h
@@ -88,8 +88,7 @@ GType nm_dhcp_manager_get_type (void);
NMDHCPManager *nm_dhcp_manager_get (void);
gboolean nm_dhcp_manager_begin_transaction (NMDHCPManager *manager,
const char *iface,
- NMSettingIP4Config *s_ip4,
- guint32 timeout);
+ NMSettingIP4Config *s_ip4);
void nm_dhcp_manager_cancel_transaction (NMDHCPManager *manager,
const char *iface);
NMIP4Config * nm_dhcp_manager_get_ip4_config (NMDHCPManager *manager, const char *iface);
diff --git a/src/nm-device.c b/src/nm-device.c
index a97986c..222b55b 100644
--- a/src/nm-device.c
+++ b/src/nm-device.c
@@ -838,7 +838,9 @@ 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, iface, s_ip4, 45);
+
+ success = nm_dhcp_manager_begin_transaction (priv->dhcp_manager, iface, s_ip4);
+
g_signal_handler_unblock (priv->dhcp_manager, priv->dhcp_state_sigid);
if (success) {
--
1.5.6.3
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]