static leases use 0, not NULL timeout

fixed static leases
This commit is contained in:
Martin Willi
2008-05-15 09:26:47 +00:00
parent bb94e1ed60
commit 89658f6d6c
3 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -158,7 +158,7 @@ CREATE TABLE pools (
`start` varbinary(16) NOT NULL, `start` varbinary(16) NOT NULL,
`end` varbinary(16) NOT NULL, `end` varbinary(16) NOT NULL,
`next` varbinary(16) NOT NULL, `next` varbinary(16) NOT NULL,
`timeout` int(10) unsigned DEFAULT NULL, `timeout` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE (`name`) UNIQUE (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+2 -2
View File
@@ -95,7 +95,7 @@ static host_t* get_lease(private_sql_attribute_t *this,
"JOIN pools AS p ON l.pool = p.id " "JOIN pools AS p ON l.pool = p.id "
"JOIN identities AS i ON l.identity = i.id " "JOIN identities AS i ON l.identity = i.id "
"WHERE p.name = ? AND i.type = ? AND i.data = ? " "WHERE p.name = ? AND i.type = ? AND i.data = ? "
"AND (l.released IS NULL OR p.timeout IS NULL " "AND (l.released IS NULL OR p.timeout = 0 "
" OR (l.released >= (? - p.timeout))) " " OR (l.released >= (? - p.timeout))) "
"ORDER BY l.acquired LIMIT 1", DB_TEXT, name, "ORDER BY l.acquired LIMIT 1", DB_TEXT, name,
DB_INT, id->get_type(id), DB_BLOB, id->get_encoding(id), DB_INT, id->get_type(id), DB_BLOB, id->get_encoding(id),
@@ -146,7 +146,7 @@ static host_t* create_lease(private_sql_attribute_t *this,
e = this->db->query(this->db, e = this->db->query(this->db,
"SELECT pool, address, released, timeout FROM leases " "SELECT pool, address, released, timeout FROM leases "
"JOIN pools ON leases.pool = pools.id " "JOIN pools ON leases.pool = pools.id "
"WHERE name = ? " "WHERE name = ? and timeout > 0 "
"GROUP BY address HAVING COUNT(released) = COUNT(*) " "GROUP BY address HAVING COUNT(released) = COUNT(*) "
"AND MAX(released) < (? - timeout) LIMIT 1", "AND MAX(released) < (? - timeout) LIMIT 1",
DB_TEXT, name, DB_UINT, time(NULL), DB_TEXT, name, DB_UINT, time(NULL),
+1 -1
View File
@@ -159,7 +159,7 @@ CREATE TABLE pools (
start BLOB NOT NULL, start BLOB NOT NULL,
end BLOB NOT NULL, end BLOB NOT NULL,
next BLOB NOT NULL, next BLOB NOT NULL,
timeout INTEGER DEFAULT NULL, timeout INTEGER NOT NULL,
UNIQUE (name) UNIQUE (name)
); );
DROP INDEX IF EXISTS pools_name; DROP INDEX IF EXISTS pools_name;