From: Alan T. DeKok Date: Wed, 10 Sep 2014 12:50:35 +0000 (-0400) Subject: When clearing entries, set expiry time to now. Addresses #786 X-Git-Tag: release_3_0_5~570 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32ed3d64204f9d2254d8ffb7c466130bd5f1ba45;p=thirdparty%2Ffreeradius-server.git 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 --- diff --git a/raddb/mods-config/sql/ippool-dhcp/mysql/queries.conf b/raddb/mods-config/sql/ippool-dhcp/mysql/queries.conf index 0a5d7effe2a..bbea23a8f93 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"