mirror of
https://github.com/topjohnwu/ndk-busybox.git
synced 2024-12-04 18:06:52 +00:00
udhcpd: account for script delay in lease
Prevent nasty surprises if script runs longer than lease time / 2. Signed-off-by: John Schroeder <jschroed@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
b9965077e5
commit
8074a6ca4d
@ -1752,7 +1752,6 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* enter bound state */
|
/* enter bound state */
|
||||||
timeout = lease_seconds / 2;
|
|
||||||
temp_addr.s_addr = packet.yiaddr;
|
temp_addr.s_addr = packet.yiaddr;
|
||||||
bb_info_msg("Lease of %s obtained, lease time %u",
|
bb_info_msg("Lease of %s obtained, lease time %u",
|
||||||
inet_ntoa(temp_addr), (unsigned)lease_seconds);
|
inet_ntoa(temp_addr), (unsigned)lease_seconds);
|
||||||
@ -1761,6 +1760,11 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
start = monotonic_sec();
|
start = monotonic_sec();
|
||||||
udhcp_run_script(&packet, state == REQUESTING ? "bound" : "renew");
|
udhcp_run_script(&packet, state == REQUESTING ? "bound" : "renew");
|
||||||
already_waited_sec = (unsigned)monotonic_sec() - start;
|
already_waited_sec = (unsigned)monotonic_sec() - start;
|
||||||
|
timeout = lease_seconds / 2;
|
||||||
|
if ((unsigned)timeout < already_waited_sec) {
|
||||||
|
/* Something went wrong. Back to discover state */
|
||||||
|
timeout = already_waited_sec = 0;
|
||||||
|
}
|
||||||
|
|
||||||
state = BOUND;
|
state = BOUND;
|
||||||
change_listen_mode(LISTEN_NONE);
|
change_listen_mode(LISTEN_NONE);
|
||||||
|
Loading…
Reference in New Issue
Block a user