Skip to content

Commit

Permalink
When clearing entries, set expiry time to now. Addresses #786
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alandekok committed Sep 10, 2014
1 parent c0715ec commit 32ed3d6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions raddb/mods-config/sql/ippool-dhcp/mysql/queries.conf
Expand Up @@ -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}'"

Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 32ed3d6

Please sign in to comment.