correctly reassigning valid leases
authorMartin Willi <martin@strongswan.org>
Fri, 9 May 2008 12:22:20 +0000 (12:22 -0000)
committerMartin Willi <martin@strongswan.org>
Fri, 9 May 2008 12:22:20 +0000 (12:22 -0000)
src/charon/plugins/sql/sql_attribute.c

index 2032b42..717d8fe 100644 (file)
@@ -96,9 +96,10 @@ static host_t* get_lease(private_sql_attribute_t *this,
                                                "JOIN identities AS i ON l.identity = i.id "
                                                "WHERE p.name = ? AND i.type = ? AND i.data = ? "
                                                "AND (l.release ISNULL OR p.timeout ISNULL "
-                                               " OR (l.release < (p.timeout + l.acquire))) "
+                                               " OR (l.release >= (? - p.timeout))) "
                                                "ORDER BY l.acquire LIMIT 1", DB_TEXT, name,
                                                DB_INT, id->get_type(id), DB_BLOB, id->get_encoding(id),
+                                               DB_UINT, time(NULL),
                                                DB_INT, DB_BLOB);
        if (e)
        {