diff options
author | Daniel Drake <dsd@laptop.org> | 2009-07-15 13:48:28 -0400 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2009-07-15 13:48:28 -0400 |
commit | 0f56957b77b0d86cf4cae3141e70f777cfc8847f (patch) | |
tree | 1fadeed6beb6c3e23cf7c328aa01262379f51718 | |
parent | 14bc75edaad5fbe5615977b3c52c29e0bbb9d713 (diff) |
core: allow device subclasses to override DHCP timeout
-rw-r--r-- | src/dhcp-manager/nm-dhcp-manager.c | 12 | ||||
-rw-r--r-- | src/nm-device.c | 13 | ||||
-rw-r--r-- | 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 66044d72f0..22368b9677 100644 --- a/src/dhcp-manager/nm-dhcp-manager.c +++ b/src/dhcp-manager/nm-dhcp-manager.c | |||
@@ -508,8 +508,7 @@ nm_dhcp_manager_handle_timeout (gpointer user_data) | |||
508 | { | 508 | { |
509 | NMDHCPDevice *device = (NMDHCPDevice *) user_data; | 509 | NMDHCPDevice *device = (NMDHCPDevice *) user_data; |
510 | 510 | ||
511 | nm_info ("(%s): DHCP transaction took too long (>%ds), stopping it.", | 511 | nm_info ("(%s): DHCP transaction took too long, stopping it.", device->iface); |
512 | device->iface, NM_DHCP_TIMEOUT); | ||
513 | 512 | ||
514 | nm_dhcp_manager_cancel_transaction (device->manager, device->iface); | 513 | nm_dhcp_manager_cancel_transaction (device->manager, device->iface); |
515 | 514 | ||
@@ -625,7 +624,11 @@ nm_dhcp_manager_begin_transaction (NMDHCPManager *manager, | |||
625 | setting = s_ip4 ? g_object_ref (s_ip4) : NULL; | 624 | setting = s_ip4 ? g_object_ref (s_ip4) : NULL; |
626 | } | 625 | } |
627 | 626 | ||
628 | nm_info ("Activation (%s) Beginning DHCP transaction.", iface); | 627 | if (timeout == 0) |
628 | timeout = NM_DHCP_TIMEOUT; | ||
629 | |||
630 | nm_info ("Activation (%s) Beginning DHCP transaction (timeout in %d seconds)", | ||
631 | iface, timeout); | ||
629 | device->pid = nm_dhcp_client_start (device, uuid, setting); | 632 | device->pid = nm_dhcp_client_start (device, uuid, setting); |
630 | 633 | ||
631 | if (setting) | 634 | if (setting) |
@@ -634,9 +637,6 @@ nm_dhcp_manager_begin_transaction (NMDHCPManager *manager, | |||
634 | if (device->pid == 0) | 637 | if (device->pid == 0) |
635 | return FALSE; | 638 | return FALSE; |
636 | 639 | ||
637 | if (timeout == 0) | ||
638 | timeout = NM_DHCP_TIMEOUT; | ||
639 | |||
640 | /* Set up a timeout on the transaction to kill it after the timeout */ | 640 | /* Set up a timeout on the transaction to kill it after the timeout */ |
641 | device->timeout_id = g_timeout_add_seconds (timeout, | 641 | device->timeout_id = g_timeout_add_seconds (timeout, |
642 | nm_dhcp_manager_handle_timeout, | 642 | nm_dhcp_manager_handle_timeout, |
diff --git a/src/nm-device.c b/src/nm-device.c index 7cefbe5082..401d529af6 100644 --- a/src/nm-device.c +++ b/src/nm-device.c | |||
@@ -89,6 +89,7 @@ typedef struct { | |||
89 | /* IP configuration info */ | 89 | /* IP configuration info */ |
90 | NMIP4Config * ip4_config; /* Config from DHCP, PPP, or system config files */ | 90 | NMIP4Config * ip4_config; /* Config from DHCP, PPP, or system config files */ |
91 | NMDHCPManager * dhcp_manager; | 91 | NMDHCPManager * dhcp_manager; |
92 | guint32 dhcp_timeout; | ||
92 | gulong dhcp_state_sigid; | 93 | gulong dhcp_state_sigid; |
93 | gulong dhcp_timeout_sigid; | 94 | gulong dhcp_timeout_sigid; |
94 | NMDHCP4Config * dhcp4_config; | 95 | NMDHCP4Config * dhcp4_config; |
@@ -142,6 +143,7 @@ nm_device_init (NMDevice *self) | |||
142 | priv->capabilities = NM_DEVICE_CAP_NONE; | 143 | priv->capabilities = NM_DEVICE_CAP_NONE; |
143 | memset (&priv->ip6_address, 0, sizeof (struct in6_addr)); | 144 | memset (&priv->ip6_address, 0, sizeof (struct in6_addr)); |
144 | priv->state = NM_DEVICE_STATE_UNMANAGED; | 145 | priv->state = NM_DEVICE_STATE_UNMANAGED; |
146 | priv->dhcp_timeout = 0; | ||
145 | } | 147 | } |
146 | 148 | ||
147 | static GObject* | 149 | static GObject* |
@@ -899,7 +901,7 @@ real_act_stage3_ip_config_start (NMDevice *self, NMDeviceStateReason *reason) | |||
899 | /* DHCP manager will cancel any transaction already in progress and we do not | 901 | /* DHCP manager will cancel any transaction already in progress and we do not |
900 | want to cancel this activation if we get "down" state from that. */ | 902 | want to cancel this activation if we get "down" state from that. */ |
901 | g_signal_handler_block (priv->dhcp_manager, priv->dhcp_state_sigid); | 903 | g_signal_handler_block (priv->dhcp_manager, priv->dhcp_state_sigid); |
902 | success = nm_dhcp_manager_begin_transaction (priv->dhcp_manager, ip_iface, uuid, s_ip4, 45); | 904 | success = nm_dhcp_manager_begin_transaction (priv->dhcp_manager, ip_iface, uuid, s_ip4, priv->dhcp_timeout); |
903 | g_signal_handler_unblock (priv->dhcp_manager, priv->dhcp_state_sigid); | 905 | g_signal_handler_unblock (priv->dhcp_manager, priv->dhcp_state_sigid); |
904 | 906 | ||
905 | if (success) { | 907 | if (success) { |
@@ -2536,3 +2538,12 @@ nm_device_spec_match_list (NMDeviceInterface *device, const GSList *specs) | |||
2536 | return FALSE; | 2538 | return FALSE; |
2537 | } | 2539 | } |
2538 | 2540 | ||
2541 | void | ||
2542 | nm_device_set_dhcp_timeout (NMDevice *device, | ||
2543 | guint32 timeout) | ||
2544 | { | ||
2545 | g_return_if_fail (NM_IS_DEVICE (device)); | ||
2546 | |||
2547 | NM_DEVICE_GET_PRIVATE (device)->dhcp_timeout = timeout; | ||
2548 | } | ||
2549 | |||
diff --git a/src/nm-device.h b/src/nm-device.h index d460352123..39003938a8 100644 --- a/src/nm-device.h +++ b/src/nm-device.h | |||
@@ -162,6 +162,8 @@ void nm_device_set_managed (NMDevice *device, | |||
162 | gboolean managed, | 162 | gboolean managed, |
163 | NMDeviceStateReason reason); | 163 | NMDeviceStateReason reason); |
164 | 164 | ||
165 | void nm_device_set_dhcp_timeout (NMDevice *device, guint32 timeout); | ||
166 | |||
165 | G_END_DECLS | 167 | G_END_DECLS |
166 | 168 | ||
167 | #endif /* NM_DEVICE_H */ | 169 | #endif /* NM_DEVICE_H */ |