[sr-dev] git:master:5fde5e87: Merge pull request #1242 from gaaf/random-fixes

GitHub noreply at github.com
Sat Sep 23 07:58:49 CEST 2017


Module: kamailio
Branch: master
Commit: 5fde5e87a0dba18c7d1d1cd97ef4e89536cc10c5
URL: https://github.com/kamailio/kamailio/commit/5fde5e87a0dba18c7d1d1cd97ef4e89536cc10c5

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: GitHub <noreply at github.com>
Date: 2017-09-23T07:58:38+02:00

Merge pull request #1242 from gaaf/random-fixes

Random fixes

---

Modified: src/modules/cfgutils/cfgutils.c
Modified: src/modules/janssonrpcc/janssonrpcc_mod.c
Modified: src/modules/json/json_mod.c

---

Diff:  https://github.com/kamailio/kamailio/commit/5fde5e87a0dba18c7d1d1cd97ef4e89536cc10c5.diff
Patch: https://github.com/kamailio/kamailio/commit/5fde5e87a0dba18c7d1d1cd97ef4e89536cc10c5.patch

---

diff --git a/src/modules/cfgutils/cfgutils.c b/src/modules/cfgutils/cfgutils.c
index ca7bf77ae3..4a3e001e6e 100644
--- a/src/modules/cfgutils/cfgutils.c
+++ b/src/modules/cfgutils/cfgutils.c
@@ -134,9 +134,9 @@ static cmd_export_t cmds[]={
 		ANY_ROUTE},
 	{"rand_event",      (cmd_function)rand_event, 0, 0, 0,
 		ANY_ROUTE},
-	{"sleep",  (cmd_function)m_sleep,  1, fixup_igp_null, 0,
+	{"sleep",  (cmd_function)m_sleep,  1, fixup_igp_null, fixup_free_igp_null,
 		ANY_ROUTE},
-	{"usleep", (cmd_function)m_usleep, 1, fixup_igp_null, 0,
+	{"usleep", (cmd_function)m_usleep, 1, fixup_igp_null, fixup_free_igp_null,
 		ANY_ROUTE},
 	{"abort",      (cmd_function)dbg_abort,        0, 0, 0,
 		ANY_ROUTE},
@@ -162,9 +162,9 @@ static cmd_export_t cmds[]={
 		ANY_ROUTE},
 	{"core_hash",    (cmd_function)w_core_hash, 3,   fixup_core_hash, 0,
 		ANY_ROUTE},
-	{"check_route_exists",    (cmd_function)w_check_route_exists, 1,   0, 0,
+	{"check_route_exists",    (cmd_function)w_check_route_exists, 1,   fixup_spve_null, fixup_free_spve_null,
 		ANY_ROUTE},
-	{"route_if_exists",    (cmd_function)w_route_exists, 1,   0, 0,
+	{"route_if_exists",    (cmd_function)w_route_exists, 1,   fixup_spve_null, fixup_free_spve_null,
 		ANY_ROUTE},
 	{"bind_cfgutils", (cmd_function)bind_cfgutils,  0,
 		0, 0, 0},
@@ -622,7 +622,6 @@ static int m_sleep(struct sip_msg *msg, char *time, char *str2)
 		LM_ERR("cannot get time interval value\n");
 		return -1;
 	}
-	LM_DBG("sleep %lu seconds\n", (unsigned long)s);
 	sleep((unsigned int)s);
 	return 1;
 }
@@ -635,7 +634,6 @@ static int m_usleep(struct sip_msg *msg, char *time, char *str2)
 		LM_ERR("cannot get time interval value\n");
 		return -1;
 	}
-	LM_DBG("sleep %lu microseconds\n", (unsigned long)time);
 	sleep_us((unsigned int)s);
 	return 1;
 }
@@ -784,7 +782,14 @@ static int w_cfg_trylock(struct sip_msg *msg, char *key, char *s2)
  */
 static int w_check_route_exists(struct sip_msg *msg, char *route)
 {
-	if (route_lookup(&main_rt, route)<0) {
+	str s;
+
+	if (fixup_get_svalue(msg, (gparam_p) route, &s) != 0)
+	{
+			LM_ERR("invalid route parameter\n");
+			return -1;
+	}
+	if (route_lookup(&main_rt, s.s)<0) {
 		/* not found */
 		return -1;
 	}
@@ -797,16 +802,27 @@ static int w_route_exists(struct sip_msg *msg, char *route)
 {
 	struct run_act_ctx ctx;
 	int newroute, backup_rt, ret;
+	str s;
 
-	newroute = route_lookup(&main_rt, route);
+	if (fixup_get_svalue(msg, (gparam_p) route, &s) != 0)
+	{
+			LM_ERR("invalid route parameter\n");
+			return -1;
+	}
+
+	newroute = route_lookup(&main_rt, s.s);
 	if (newroute<0) {
 		return -1;
 	}
 	backup_rt = get_route_type();
 	set_route_type(REQUEST_ROUTE);
+
 	init_run_actions_ctx(&ctx);
 	ret = run_top_route(main_rt.rlist[newroute], msg, &ctx);
 	set_route_type(backup_rt);
+	if (ctx.run_flags & EXIT_R_F) {
+		return 0;
+	}
 	return ret;
 }
 
diff --git a/src/modules/janssonrpcc/janssonrpcc_mod.c b/src/modules/janssonrpcc/janssonrpcc_mod.c
index a6e9c010d3..5cdd5f8a5b 100644
--- a/src/modules/janssonrpcc/janssonrpcc_mod.c
+++ b/src/modules/janssonrpcc/janssonrpcc_mod.c
@@ -205,8 +205,10 @@ static int child_init(int rank)
 
 void mod_destroy(void)
 {
-	lock_get(jsonrpc_server_group_lock); /* blocking */
-	if(jsonrpc_server_group_lock) lock_dealloc(jsonrpc_server_group_lock);
+	if(jsonrpc_server_group_lock) {
+		lock_get(jsonrpc_server_group_lock); /* blocking */
+		lock_dealloc(jsonrpc_server_group_lock);
+	}
 
 	free_server_group(global_server_group);
 	CHECK_AND_FREE(global_server_group);
diff --git a/src/modules/json/json_mod.c b/src/modules/json/json_mod.c
index b20299efe9..ec7a5fced3 100644
--- a/src/modules/json/json_mod.c
+++ b/src/modules/json/json_mod.c
@@ -82,7 +82,7 @@ static int fixup_get_field(void** param, int param_no)
 static int fixup_get_field_free(void** param, int param_no)
 {
 	if (param_no == 1 || param_no == 2) {
-		LM_WARN("free function has not been defined for spve\n");
+		fixup_free_spve_null(param, 1);
 		return 0;
 	}
 




More information about the sr-dev mailing list