[PATCH] udhcpd: keep expired leases at startup

Christian Lindeberg christian.lindeberg at axis.com
Wed Mar 2 10:49:08 UTC 2016


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()?

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];

If there are multiple candidates for the oldest, the last candidate is now
picked if there are empty entries otherwise the first candidate is picked as
before the change.

Won't this just cause more store operations (though not a dramatic amount) as
long as the server hasn't handed out all it's leases?

Regards,
Christian


More information about the busybox mailing list