[sr-dev] git:master:7004969c: dialog: execute pre script callback only when event route is set

Daniel-Constantin Mierla miconda at gmail.com
Fri Apr 21 21:42:48 CEST 2017


Module: kamailio
Branch: master
Commit: 7004969cf94815167d72d2e7158e4754c730ff1d
URL: https://github.com/kamailio/kamailio/commit/7004969cf94815167d72d2e7158e4754c730ff1d

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-04-21T19:59:38+02:00

dialog: execute pre script callback only when event route is set

---

Modified: src/core/script_cb.c
Modified: src/modules/dialog/dlg_handlers.c

---

Diff:  https://github.com/kamailio/kamailio/commit/7004969cf94815167d72d2e7158e4754c730ff1d.diff
Patch: https://github.com/kamailio/kamailio/commit/7004969cf94815167d72d2e7158e4754c730ff1d.patch

---

diff --git a/src/core/script_cb.c b/src/core/script_cb.c
index 5e1547e..efd76cf 100644
--- a/src/core/script_cb.c
+++ b/src/core/script_cb.c
@@ -18,15 +18,15 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */
 
 /*!
  * \file
- * \brief Kamailio core :: Script callbacks 
+ * \brief Kamailio core :: Script callbacks
  *
  * Script callbacks adds the ability to register callback
  * functions which are always called when script for request
@@ -151,12 +151,11 @@ int exec_pre_script_cb( struct sip_msg *msg, enum script_cb_type type)
 	struct script_cb	*cb;
 	unsigned int	flags;
 
-#ifdef EXTRA_DEBUG
 	if (type > SCRIPT_CB_NUM) {
-		LOG(L_BUG, "Uknown callback type\n");
-		abort();
+		LOG(L_BUG, "Uknown callback type %d\n", type);
+		return 0;
 	}
-#endif
+
 	flags = PRE_SCRIPT_CB | (1<<(type-1));
 	for (cb=pre_script_cb[type-1]; cb ; cb=cb->next ) {
 		/* stop on error */
@@ -174,12 +173,11 @@ int exec_post_script_cb( struct sip_msg *msg, enum script_cb_type type)
 	struct script_cb	*cb;
 	unsigned int	flags;
 
-#ifdef EXTRA_DEBUG
 	if (type > SCRIPT_CB_NUM) {
-		LOG(L_BUG, "exec_pre_script_cb: Uknown callback type\n");
-		abort();
+		LOG(L_BUG, "Uknown callback type %d\n", type);
+		return 1;
 	}
-#endif
+
 	flags = POST_SCRIPT_CB | (1<<(type-1));
 	for (cb=post_script_cb[type-1]; cb ; cb=cb->next){
 		cb->cbf(msg, flags, cb->param);
diff --git a/src/modules/dialog/dlg_handlers.c b/src/modules/dialog/dlg_handlers.c
index 2eb36f5..030847b 100644
--- a/src/modules/dialog/dlg_handlers.c
+++ b/src/modules/dialog/dlg_handlers.c
@@ -61,7 +61,7 @@ static str       rr_param;		/*!< record-route parameter for matching */
 static int       dlg_flag_mask=0;	/*!< flag for dialog tracking */
 static pv_spec_t *timeout_avp;		/*!< AVP for timeout setting */
 static int       default_timeout;	/*!< default dialog timeout */
-static int       seq_match_mode;	/*!< dlg_match mode */ 
+static int       seq_match_mode;	/*!< dlg_match mode */
 static int       shutdown_done = 0;	/*!< 1 when destroy_dlg_handlers was called */
 extern int       detect_spirals;
 extern int       dlg_timeout_noreset;
@@ -171,7 +171,7 @@ static inline int add_dlg_rr_param(struct sip_msg *req, unsigned int entry,
 /*!
  * \brief Parse SIP message and populate leg informations
  *
- * Parse SIP message and populate leg informations. 
+ * Parse SIP message and populate leg informations.
  * \param dlg the dialog to add cseq, contact & record_route
  * \param msg sip message
  * \param t transaction
@@ -813,7 +813,7 @@ static void unref_new_dialog(void *iuid)
  * \param t transaction
  * \param run_initial_cbs if set zero, initial callbacks are not executed
  * \return 0 on success, -1 on failure
- */ 
+ */
 int dlg_new_dialog(sip_msg_t *req, struct cell *t, const int run_initial_cbs)
 {
 	dlg_cell_t *dlg;
@@ -1191,7 +1191,7 @@ dlg_cell_t *dlg_lookup_msg_dialog(sip_msg_t *msg, unsigned int *dir)
 		}
 		return dlg;
 	}
-	
+
 	if (pre_match_parse(msg, &callid, &ftag, &ttag, 0)<0)
 		return NULL;
 	vdir = DLG_DIR_NONE;
@@ -1723,16 +1723,15 @@ void dlg_run_event_route(dlg_cell_t *dlg, sip_msg_t *msg, int ostate, int nstate
 		}
 	}
 
+	if(rt>=0 || dlg_event_callback.len>0) {
+		if(msg==NULL)
+			fmsg = faked_msg_next();
+		else
+			fmsg = msg;
 
-	if(msg==NULL)
-		fmsg = faked_msg_next();
-	else
-		fmsg = msg;
-
-	if (exec_pre_script_cb(fmsg, LOCAL_CB_TYPE)<=0)
-		return;
+		if (exec_pre_script_cb(fmsg, LOCAL_CB_TYPE)<=0)
+			return;
 
-	if(rt>=0 || dlg_event_callback.len>0) {
 		dlg_ref(dlg, 1);
 		dlg_set_ctx_iuid(dlg);
 		LM_DBG("executing event_route %d on state %d\n", rt, nstate);




More information about the sr-dev mailing list