[sr-dev] git:master:18c1eb2c: Merge pull request #1626 from kamailio/dmq_handle_message-return

GitHub noreply at github.com
Fri Aug 31 20:50:11 CEST 2018


Module: kamailio
Branch: master
Commit: 18c1eb2c05c9eadea240677db27576caaef0950c
URL: https://github.com/kamailio/kamailio/commit/18c1eb2c05c9eadea240677db27576caaef0950c

Author: Charles Chance <charles.chance at sipcentric.com>
Committer: GitHub <noreply at github.com>
Date: 2018-08-31T19:50:05+01:00

Merge pull request #1626 from kamailio/dmq_handle_message-return

dmq: add optional "continue" parameter to dmq_handle_message()

---

Modified: src/modules/dmq/dmq.c
Modified: src/modules/dmq/doc/dmq_admin.xml
Modified: src/modules/dmq/message.c
Modified: src/modules/dmq/message.h

---

Diff:  https://github.com/kamailio/kamailio/commit/18c1eb2c05c9eadea240677db27576caaef0950c.diff
Patch: https://github.com/kamailio/kamailio/commit/18c1eb2c05c9eadea240677db27576caaef0950c.patch

---

diff --git a/src/modules/dmq/dmq.c b/src/modules/dmq/dmq.c
index b374b8de31..d28686da9c 100644
--- a/src/modules/dmq/dmq.c
+++ b/src/modules/dmq/dmq.c
@@ -91,6 +91,8 @@ static void destroy(void);
 static cmd_export_t cmds[] = {
 	{"dmq_handle_message", (cmd_function)dmq_handle_message, 0,
 		0, 0, REQUEST_ROUTE},
+	{"dmq_handle_message", (cmd_function)w_dmq_handle_message, 1,
+		fixup_int_1, 0, REQUEST_ROUTE},
 	{"dmq_send_message", (cmd_function)cfg_dmq_send_message, 4,
 		fixup_spve_all, 0, ANY_ROUTE},
 	{"dmq_bcast_message", (cmd_function)cfg_dmq_bcast_message, 3,
@@ -412,4 +414,4 @@ int mod_register(char *path, int *dlflags, void *p1, void *p2)
 {
 	sr_kemi_modules_add(sr_kemi_dmq_exports);
 	return 0;
-}
\ No newline at end of file
+}
diff --git a/src/modules/dmq/doc/dmq_admin.xml b/src/modules/dmq/doc/dmq_admin.xml
index 0903f6b40c..26555e24a3 100644
--- a/src/modules/dmq/doc/dmq_admin.xml
+++ b/src/modules/dmq/doc/dmq_admin.xml
@@ -219,12 +219,22 @@ modparam("dmq", "ping_interval", 90)
         <title>Functions</title>
         <section id="dmq.f.dmq_handle_message">
                 <title>
-                <function moreinfo="none">dmq_handle_message()</function>
+                <function moreinfo="none">dmq_handle_message([continue])</function>
                 </title>
                 <para>
                 Handles a DMQ message by passing it to the appropriate local peer (module).
 		The peer is identified by the user part of the To header.
                 </para>
+                <para>Meaning of parameters:</para>
+                <itemizedlist>
+                        <listitem>
+                                <para>
+                                <emphasis>continue</emphasis> - by default, dmq_handle_message() will end
+                                execution of routing script. If this optional parameter is set to "1", dmq_handle_message()
+                                will continue executing the routing script after it's been called.
+                                </para>
+                        </listitem>
+                </itemizedlist>
                 <para>
                 This function can be used from REQUEST_ROUTE.
                 </para>
diff --git a/src/modules/dmq/message.c b/src/modules/dmq/message.c
index 679f671fc6..2293cc3600 100644
--- a/src/modules/dmq/message.c
+++ b/src/modules/dmq/message.c
@@ -40,7 +40,7 @@ str dmq_404_rpl = str_init("User Not Found");
 /**
  * @brief config function to handle dmq messages
  */
-int ki_dmq_handle_message(sip_msg_t *msg)
+int ki_dmq_handle_message(sip_msg_t *msg, int returnval)
 {
 	dmq_peer_t *peer;
 	if((parse_sip_msg_uri(msg) < 0) || (!msg->parsed_uri.user.s)) {
@@ -60,7 +60,7 @@ int ki_dmq_handle_message(sip_msg_t *msg)
 			LM_ERR("sending reply\n");
 			goto error;
 		}
-		return 0;
+		return returnval;
 	}
 	LM_DBG("dmq_handle_message peer found: %.*s\n", msg->parsed_uri.user.len,
 			msg->parsed_uri.user.s);
@@ -68,12 +68,22 @@ int ki_dmq_handle_message(sip_msg_t *msg)
 		LM_ERR("failed to add dmq job\n");
 		goto error;
 	}
-	return 0;
+	return returnval;
 error:
 	return -1;
 }
 
+int w_dmq_handle_message(struct sip_msg *msg, char *str1, char *str2)
+{
+	int i = 0;
+	if(str1) {
+		if(get_int_fparam(&i, msg, (fparam_t*)str1)<0) return -1;
+	}
+	if(i>1) i = 1;
+	return ki_dmq_handle_message(msg, i);
+}
+
 int dmq_handle_message(struct sip_msg *msg, char *str1, char *str2)
 {
-	return ki_dmq_handle_message(msg);
-}
\ No newline at end of file
+	return ki_dmq_handle_message(msg, 0);
+}
diff --git a/src/modules/dmq/message.h b/src/modules/dmq/message.h
index 5131f87c02..9c9f835745 100644
--- a/src/modules/dmq/message.h
+++ b/src/modules/dmq/message.h
@@ -24,7 +24,8 @@
 #ifndef _MESSAGE_H_
 #define _MESSAGE_H_
 
+int w_dmq_handle_message(struct sip_msg *, char *str1, char *str2);
 int dmq_handle_message(struct sip_msg *, char *str1, char *str2);
-int ki_dmq_handle_message(sip_msg_t *msg);
+int ki_dmq_handle_message(sip_msg_t *msg, int returnval);
 
 #endif




More information about the sr-dev mailing list