be less racy with dhcdbd's change to bound state

git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@972 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Peter Jones 2005-09-21 15:33:10 +00:00
parent 71b1632ad2
commit 394abb5977

View file

@ -24,6 +24,7 @@
#include "nm-dhcp-manager.h"
#include "NetworkManagerDevice.h"
#include "NetworkManagerPolicy.h"
#include "NetworkManagerUtils.h"
#include "nm-activation-request.h"
#include "nm-utils.h"
#include <sys/socket.h>
@ -439,6 +440,16 @@ static gboolean get_ip4_string (NMDHCPManager *manager, NMDevice *dev, const cha
}
static gboolean nm_completion_dhcp_bound_test(int tries,
nm_completion_args args)
{
NMActRequest *req = args[0];
if (state_is_bound (nm_act_request_get_dhcp_state (req)))
return TRUE;
return FALSE;
}
/*
* nm_dhcp_manager_get_ip4_config
*
@ -459,6 +470,7 @@ NMIP4Config * nm_dhcp_manager_get_ip4_config (NMDHCPManager *manager, NMActReque
guint32 num_ip4_nameservers = 0;
char * domain_names = NULL;
struct in_addr temp_addr;
nm_completion_args args;
g_return_val_if_fail (manager != NULL, NULL);
g_return_val_if_fail (req != NULL, NULL);
@ -469,6 +481,9 @@ NMIP4Config * nm_dhcp_manager_get_ip4_config (NMDHCPManager *manager, NMActReque
dev = nm_act_request_get_dev (req);
g_assert (dev);
args[0] = req;
nm_wait_for_completion (30, G_USEC_PER_SEC / 10,
nm_completion_dhcp_bound_test, NULL, args);
if (!state_is_bound (nm_act_request_get_dhcp_state (req)))
{
nm_warning ("Tried to get IP4 Config for a device when dhcdbd wasn't in a BOUND state!");