Ticket #13385: dhcp_test.patch

File dhcp_test.patch, 1.1 KB (added by tqh, 8 years ago)

Very short initial timeout

  • src/servers/net/DHCPClient.cpp

    diff --git a/src/servers/net/DHCPClient.cpp b/src/servers/net/DHCPClient.cpp
    index d5ffd0e..211fc6c 100644
    a b  
    3939#define DHCP_CLIENT_PORT    68
    4040#define DHCP_SERVER_PORT    67
    4141
    42 #define DEFAULT_TIMEOUT     4   // secs
     42#define DEFAULT_TIMEOUT     1   // secs
    4343#define MAX_TIMEOUT         64  // secs
    4444
    4545#define MAX_RETRIES         5
    DHCPClient::~DHCPClient()  
    489489status_t
    490490DHCPClient::Initialize()
    491491{
     492    bool old = fAssignedAddress == 0;
    492493    fStatus = _Negotiate(fAssignedAddress == 0 ? INIT : INIT_REBOOT);
    493     syslog(LOG_DEBUG, "%s: DHCP status = %s\n", Device(), strerror(fStatus));
     494    syslog(LOG_DEBUG, "%s: DHCP status = %s %s\n", Device(), strerror(fStatus), old ? "reusing": "");
    494495    return fStatus;
    495496}
    496497
    DHCPClient::_ResetTimeout(int socket, dhcp_state& state, time_t& timeout,  
    901902    tries = 0;
    902903
    903904    struct timeval value;
    904     value.tv_sec = timeout;
    905     value.tv_usec = rand() % 1000000;
     905    value.tv_sec = 0;
     906    value.tv_usec = 200000 + rand() % 200000;
    906907    setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, &value, sizeof(value));
    907908}
    908909