# HG changeset patch # User gthomas # Date 1168886272 0 # Node ID 15a55713925464e6308c04bda7c6213c751deb8a # Parent bafbb0c01fb467dfa995ce17989b1ae39ce31ff7 Fix for DHCP when server is down after lease expires (keep trying) diff --git a/packages/net/common/current/ChangeLog b/packages/net/common/current/ChangeLog --- a/packages/net/common/current/ChangeLog +++ b/packages/net/common/current/ChangeLog @@ -1,3 +1,9 @@ +2007-01-15 Gary Thomas + + * src/dhcp_support.c (dhcp_mgt_entry): Better handling when restarting + interfaces after expired lease(s). Keep trying in case the DHCP server + has gone down. + 2007-01-09 Jonathan Larmour * doc/manpages/net/getaddrinfo.3: Remove obsolete comment about diff --git a/packages/net/common/current/src/dhcp_support.c b/packages/net/common/current/src/dhcp_support.c --- a/packages/net/common/current/src/dhcp_support.c +++ b/packages/net/common/current/src/dhcp_support.c @@ -196,9 +196,19 @@ int dhcp_release( void ) // ------------------------------------------------------------------------ // The management thread function +// +// Note: 2007-01-15 +// This single management thread attempts to keep all configured +// interfaces alive via DHCP. While this may be sufficient for +// many systems, it falls short of perfect. There should probably +// be a separate thread for each possible interface, along with +// appropriate CDL to control how each inteface is managed. +// void dhcp_mgt_entry( cyg_addrword_t loop_on_failure ) { int j; + bool any_interfaces_up; + while ( 1 ) { while ( 1 ) { cyg_semaphore_wait( &dhcp_needs_attention ); @@ -208,7 +218,17 @@ void dhcp_mgt_entry( cyg_addrword_t loop dhcp_halt(); // tear everything down if ( !loop_on_failure ) return; // exit the thread/return - init_all_network_interfaces(); // re-initialize + do { + init_all_network_interfaces(); // re-initialize + // If at least one interface is up, then the DHCP machine will run + any_interfaces_up = false; +#ifdef CYGHWR_NET_DRIVER_ETH0 + any_interfaces_up |= eth0_up; +#endif +#ifdef CYGHWR_NET_DRIVER_ETH1 + any_interfaces_up |= eth1_up; +#endif + } while (!any_interfaces_up); for ( j = 0; j < CYGPKG_NET_NLOOP; j++ ) init_loopback_interface( j ); #ifdef CYGPKG_SNMPAGENT