sd-dhcp-client: minor simplification
This commit is contained in:
parent
573b02f5c1
commit
e4dc0845bc
|
@ -1187,7 +1187,7 @@ static int client_timeout_resend(
|
||||||
|
|
||||||
sd_dhcp_client *client = userdata;
|
sd_dhcp_client *client = userdata;
|
||||||
DHCP_CLIENT_DONT_DESTROY(client);
|
DHCP_CLIENT_DONT_DESTROY(client);
|
||||||
usec_t next_timeout = 0;
|
usec_t next_timeout;
|
||||||
uint64_t time_now;
|
uint64_t time_now;
|
||||||
uint32_t time_left;
|
uint32_t time_left;
|
||||||
int r;
|
int r;
|
||||||
|
@ -1203,17 +1203,14 @@ static int client_timeout_resend(
|
||||||
switch (client->state) {
|
switch (client->state) {
|
||||||
|
|
||||||
case DHCP_STATE_RENEWING:
|
case DHCP_STATE_RENEWING:
|
||||||
|
|
||||||
time_left = (client->lease->t2 - client->lease->t1) / 2;
|
time_left = (client->lease->t2 - client->lease->t1) / 2;
|
||||||
if (time_left < 60)
|
if (time_left < 60)
|
||||||
time_left = 60;
|
time_left = 60;
|
||||||
|
|
||||||
next_timeout = time_now + time_left * USEC_PER_SEC;
|
next_timeout = time_now + time_left * USEC_PER_SEC;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DHCP_STATE_REBINDING:
|
case DHCP_STATE_REBINDING:
|
||||||
|
|
||||||
time_left = (client->lease->lifetime - client->lease->t2) / 2;
|
time_left = (client->lease->lifetime - client->lease->t2) / 2;
|
||||||
if (time_left < 60)
|
if (time_left < 60)
|
||||||
time_left = 60;
|
time_left = 60;
|
||||||
|
@ -1230,24 +1227,20 @@ static int client_timeout_resend(
|
||||||
r = client_start(client);
|
r = client_start(client);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto error;
|
goto error;
|
||||||
else {
|
|
||||||
log_dhcp_client(client, "REBOOTED");
|
log_dhcp_client(client, "REBOOTED");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
case DHCP_STATE_INIT:
|
case DHCP_STATE_INIT:
|
||||||
case DHCP_STATE_INIT_REBOOT:
|
case DHCP_STATE_INIT_REBOOT:
|
||||||
case DHCP_STATE_SELECTING:
|
case DHCP_STATE_SELECTING:
|
||||||
case DHCP_STATE_REQUESTING:
|
case DHCP_STATE_REQUESTING:
|
||||||
case DHCP_STATE_BOUND:
|
case DHCP_STATE_BOUND:
|
||||||
|
if (client->attempt >= client->max_attempts)
|
||||||
if (client->attempt < client->max_attempts)
|
|
||||||
client->attempt++;
|
|
||||||
else
|
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
client->attempt++;
|
||||||
next_timeout = time_now + ((UINT64_C(1) << MIN(client->attempt, (uint64_t) 6)) - 1) * USEC_PER_SEC;
|
next_timeout = time_now + ((UINT64_C(1) << MIN(client->attempt, (uint64_t) 6)) - 1) * USEC_PER_SEC;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DHCP_STATE_STOPPED:
|
case DHCP_STATE_STOPPED:
|
||||||
|
@ -1295,12 +1288,10 @@ static int client_timeout_resend(
|
||||||
client->state = DHCP_STATE_REBOOTING;
|
client->state = DHCP_STATE_REBOOTING;
|
||||||
|
|
||||||
client->request_sent = time_now;
|
client->request_sent = time_now;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DHCP_STATE_REBOOTING:
|
case DHCP_STATE_REBOOTING:
|
||||||
case DHCP_STATE_BOUND:
|
case DHCP_STATE_BOUND:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DHCP_STATE_STOPPED:
|
case DHCP_STATE_STOPPED:
|
||||||
|
|
Loading…
Reference in New Issue