sql plugin supports a list of pools to fall back, specified by e.g. rightsourceip=%pool1,pool2

This commit is contained in:
Martin Willi
2008-07-02 08:31:48 +00:00
parent 11e855179e
commit d932435e18
+23 -4
View File
@@ -226,13 +226,24 @@ static host_t* acquire_address(private_sql_attribute_t *this,
char *name, identification_t *id, char *name, identification_t *id,
auth_info_t *auth, host_t *requested) auth_info_t *auth, host_t *requested)
{ {
host_t *ip; enumerator_t *enumerator;
host_t *ip = NULL;
ip = get_lease(this, name, id); enumerator = enumerator_create_token(name, ",", " ");
if (!ip) while (enumerator->enumerate(enumerator, &name))
{ {
ip = create_lease(this, name, id); ip = get_lease(this, name, id);
if (ip)
{
break;
} }
ip = create_lease(this, name, id);
if (ip)
{
break;
}
}
enumerator->destroy(enumerator);
return ip; return ip;
} }
@@ -241,6 +252,11 @@ static host_t* acquire_address(private_sql_attribute_t *this,
*/ */
static bool release_address(private_sql_attribute_t *this, static bool release_address(private_sql_attribute_t *this,
char *name, host_t *address) char *name, host_t *address)
{
enumerator_t *enumerator;
enumerator = enumerator_create_token(name, ",", " ");
while (enumerator->enumerate(enumerator, &name))
{ {
if (this->db->execute(this->db, NULL, if (this->db->execute(this->db, NULL,
"UPDATE leases SET released = ? WHERE " "UPDATE leases SET released = ? WHERE "
@@ -249,8 +265,11 @@ static bool release_address(private_sql_attribute_t *this,
DB_UINT, time(NULL), DB_UINT, time(NULL),
DB_TEXT, name, DB_BLOB, address->get_address(address)) > 0) DB_TEXT, name, DB_BLOB, address->get_address(address)) > 0)
{ {
enumerator->destroy(enumerator);
return TRUE; return TRUE;
} }
}
enumerator->destroy(enumerator);
return FALSE; return FALSE;
} }