Module: sip-router
Branch: sr_3.0
Commit: c8390476a7d30a0352beeb434920947730965a53
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c839047…
Author: Juha Heinanen <jh(a)tutpro.com>
Committer: Juha Heinanen <jh(a)tutpro.com>
Date: Sun May 9 15:55:22 2010 +0300
modules_k/permissions: backported address table reload fix from master
---
modules_k/permissions/address.c | 23 ++++++++++++++++++-----
1 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/modules_k/permissions/address.c b/modules_k/permissions/address.c
index 126c8d8..63c0cf1 100644
--- a/modules_k/permissions/address.c
+++ b/modules_k/permissions/address.c
@@ -78,6 +78,17 @@ int reload_address_table(void)
cols[2] = &mask_col;
cols[3] = &port_col;
+ if (db_handle) {
+ LM_ERR("db_handle already exists\n");
+ return -1;
+ }
+
+ db_handle = perm_dbf.init(&db_url);
+ if (!db_handle) {
+ LM_ERR("unable to connect database\n");
+ return -1;
+ }
+
if (perm_dbf.use_table(db_handle, &address_table) < 0) {
LM_ERR("failed to use table\n");
return -1;
@@ -161,6 +172,9 @@ int reload_address_table(void)
perm_dbf.free_result(db_handle, res);
+ perm_dbf.close(db_handle);
+ db_handle = 0;
+
*addr_hash_table = new_hash_table;
*subnet_table = new_subnet_table;
@@ -203,9 +217,13 @@ int init_addresses(void)
if(db_check_table_version(&perm_dbf, db_handle, &address_table,
TABLE_VERSION) < 0) {
LM_ERR("error during table version check.\n");
perm_dbf.close(db_handle);
+ db_handle = 0;
return -1;
}
+ perm_dbf.close(db_handle);
+ db_handle = 0;
+
addr_hash_table_1 = new_addr_hash_table();
if (!addr_hash_table_1) return -1;
@@ -234,9 +252,6 @@ int init_addresses(void)
goto error;
}
- perm_dbf.close(db_handle);
- db_handle = 0;
-
return 0;
error:
@@ -265,8 +280,6 @@ error:
shm_free(subnet_table);
subnet_table = 0;
}
- perm_dbf.close(db_handle);
- db_handle = 0;
return -1;
}