From 32ed3d64204f9d2254d8ffb7c466130bd5f1ba45 Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Wed, 10 Sep 2014 08:50:35 -0400 Subject: [PATCH] When clearing entries, set expiry time to now. Addresses #786 This is so that the allocate_find will return the oldest IP. And, the allocate_find will now use an index, rather than potentially scanning the entire table --- raddb/mods-config/sql/ippool-dhcp/mysql/queries.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/raddb/mods-config/sql/ippool-dhcp/mysql/queries.conf b/raddb/mods-config/sql/ippool-dhcp/mysql/queries.conf index 0a5d7effe2a5..bbea23a8f939 100644 --- a/raddb/mods-config/sql/ippool-dhcp/mysql/queries.conf +++ b/raddb/mods-config/sql/ippool-dhcp/mysql/queries.conf @@ -30,7 +30,7 @@ allocate_clear = "\ pool_key = 0, \ callingstationid = '', \ username = '', \ - expiry_time = NULL \ + expiry_time = NOW() \ WHERE expiry_time <= NOW() - INTERVAL 1 SECOND \ AND nasipaddress = '%{Nas-IP-Address}'" @@ -64,7 +64,7 @@ allocate_find = "\ # SELECT framedipaddress \ # FROM ${ippool_table} \ # WHERE pool_name = '%{control:Pool-Name}' \ -# AND expiry_time IS NULL \ +# AND expiry_time < NOW() \ # ORDER BY RAND() \ # LIMIT 1 \ # FOR UPDATE"