Module: sip-router
Branch: master
Commit: 3e3ec3e302e25936af1b24a3769a455abc138e08
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3e3ec3e…
Author: Juha Heinanen<jh(a)tutpro.com>
Committer: Juha Heinanen<jh(a)tutpro.com>
Date: Sun May 9 15:02:11 2010 +0300
modules_k/permissions: fixed reloading of address table
- Database handle was not initialized when address table was reloaded.
Now it is initialized/closed at each reload. Looks like this has
never been tested before. Still don't know why mi_addr_child_init()
exists and what it is supposed to do.
---
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 469e21a..0dd7b10 100644
--- a/modules_k/permissions/address.c
+++ b/modules_k/permissions/address.c
@@ -79,6 +79,17 @@ int reload_address_table(void)
cols[2] =&mask_col;
cols[3] =&port_col;
cols[4] =&tag_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");
@@ -166,6 +177,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;
@@ -208,9 +222,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;
@@ -245,9 +263,6 @@ int init_addresses(void)
goto error;
}
- perm_dbf.close(db_handle);
- db_handle = 0;
-
return 0;
error:
@@ -275,8 +290,6 @@ error:
shm_free(subnet_table);
subnet_table = 0;
}
- perm_dbf.close(db_handle);
- db_handle = 0;
return -1;
}
_______________________________________________
sr-dev mailing list
sr-dev(a)lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev