Module: sip-router
Branch: master
Commit: 96e760147469a385a0b5512f74afcff8f56cafd1
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=96e7601…
Author: Ovidiu Sas <osas(a)voipembedded.com>
Committer: Ovidiu Sas <osas(a)voipembedded.com>
Date: Tue Sep 17 09:24:51 2013 -0400
dispatcher: fix mi/rpc reload command
---
modules/dispatcher/dispatch.c | 26 +++++++++++++++++++++++---
modules/dispatcher/dispatch.h | 1 +
modules/dispatcher/dispatcher.c | 4 ++--
3 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/modules/dispatcher/dispatch.c b/modules/dispatcher/dispatch.c
index 2783675..56d2f06 100644
--- a/modules/dispatcher/dispatch.c
+++ b/modules/dispatcher/dispatch.c
@@ -92,7 +92,7 @@ static ds_ht_t *_dsht_load = NULL;
extern int ds_force_dst;
static db_func_t ds_dbf;
-static db1_con_t* ds_db_handle=0;
+static db1_con_t* ds_db_handle=NULL;
ds_set_t **ds_lists=NULL;
@@ -655,8 +655,8 @@ int init_ds_db(void)
return -1;
}
- if(ds_connect_db()!=0){
-
+ if(ds_connect_db()!=0)
+ {
LM_ERR("unable to connect to the database\n");
return -1;
}
@@ -689,6 +689,26 @@ int init_ds_db(void)
return ret;
}
+/*! \brief reload groups of destinations from DB*/
+int ds_reload_db(void)
+{
+ int ret;
+
+ if(ds_connect_db()!=0)
+ {
+ LM_ERR("unable to connect to the database\n");
+ return -1;
+ }
+ ret = ds_load_db();
+ if (ret == -2)
+ {
+ LM_WARN("failure while loading one or more dispatcher entries\n");
+ }
+ ds_disconnect_db();
+
+ return ret;
+}
+
/*! \brief load groups of destinations from DB*/
int ds_load_db(void)
{
diff --git a/modules/dispatcher/dispatch.h b/modules/dispatcher/dispatch.h
index 912a3e0..cfa9ac0 100644
--- a/modules/dispatcher/dispatch.h
+++ b/modules/dispatcher/dispatch.h
@@ -105,6 +105,7 @@ int ds_load_list(char *lfile);
int ds_connect_db(void);
void ds_disconnect_db(void);
int ds_load_db(void);
+int ds_reload_db(void);
int ds_destroy_list(void);
int ds_select_dst(struct sip_msg *msg, int set, int alg, int mode);
int ds_next_dst(struct sip_msg *msg, int mode);
diff --git a/modules/dispatcher/dispatcher.c b/modules/dispatcher/dispatcher.c
index 9cb5ed5..a084ce8 100644
--- a/modules/dispatcher/dispatcher.c
+++ b/modules/dispatcher/dispatcher.c
@@ -792,7 +792,7 @@ static struct mi_root* ds_mi_reload(struct mi_root* cmd_tree, void*
param)
if (ds_load_list(dslistfile)!=0)
return init_mi_tree(500, MI_ERR_RELOAD, MI_ERR_RELOAD_LEN);
} else {
- if(ds_load_db()<0)
+ if(ds_reload_db()<0)
return init_mi_tree(500, MI_ERR_RELOAD, MI_ERR_RELOAD_LEN);
}
return init_mi_tree(200, MI_OK_S, MI_OK_LEN);
@@ -956,7 +956,7 @@ static void dispatcher_rpc_reload(rpc_t* rpc, void* ctx)
return;
}
} else {
- if(ds_load_db()<0) {
+ if(ds_reload_db()<0) {
rpc->fault(ctx, 500, "Reload Failed");
return;
}