On Wed, Mar 2, 2016 at 11:49 AM, Christian Lindeberg
<[email protected]> wrote:
> On 01/03/16 19:24, Denys Vlasenko wrote:
>> Applied in a simplified form, without config option. Thanks.
>
> What is the intent of or reason for the additional change in
> oldest_expired_lease()?

The purpose is to have less broken behavior on
sizeof(time_t) == 4 machines in the year 2038,
when time_t will roll over and become negative.

Old code implicitly depended on "g_leases[i].expires < oldest_time"
being true for g_leases[i].expires = 0 (i.e. for empty entries).
This is a bit subtle, so I decided to make that explicit:
empty entry is always considered "oldest".

> diff --git a/networking/udhcp/leases.c b/networking/udhcp/leases.c
> index 844bb60..411b749 100644
> --- a/networking/udhcp/leases.c
> +++ b/networking/udhcp/leases.c
> @@ -17,7 +17,9 @@ static struct dyn_lease *oldest_expired_lease(void)
>         /* Unexpired leases have g_leases[i].expires >= current time
>          * and therefore can't ever match */
>         for (i = 0; i < server_config.max_leases; i++) {
> -               if (g_leases[i].expires < oldest_time) {
> +               if (g_leases[i].expires == 0 /* empty entry */
> +                || g_leases[i].expires < oldest_time
> +               ) {
>                         oldest_time = g_leases[i].expires;
>                         oldest_lease = &g_leases[i];
>
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to