Browse code

dialog: reset local variables shortcuts after reply and failure processing

- avoid using wrong values to find dialogs with processing of next messages
- reported by Julia Boudniatsky

(cherry picked from commit dcdb73d792719e38844eef60f821365b587893d7)

Daniel-Constantin Mierla authored on 10/12/2014 09:54:56
Showing 5 changed files
... ...
@@ -626,6 +626,16 @@ static int mod_init(void)
626 626
 		return -1;
627 627
 	}
628 628
 
629
+	if (register_script_cb( cb_dlg_locals_reset, POST_SCRIPT_CB|ONREPLY_CB_TYPE,0)<0) {
630
+		LM_ERR("cannot register reply post-script dlg locals reset callback\n");
631
+		return -1;
632
+	}
633
+
634
+	if (register_script_cb( cb_dlg_locals_reset, POST_SCRIPT_CB|FAILURE_CB_TYPE,0)<0) {
635
+		LM_ERR("cannot register failure post-script dlg locals reset callback\n");
636
+		return -1;
637
+	}
638
+
629 639
 	if(dlg_timer_procs<=0) {
630 640
 		if ( register_timer( dlg_timer_routine, 0, 1)<0 ) {
631 641
 			LM_ERR("failed to register timer \n");
... ...
@@ -409,6 +409,27 @@ int remove_profile(dlg_profile_table_t *profile, str *value, str *puid)
409 409
 
410 410
 
411 411
 /*!
412
+ * \brief Callback for cleanup of profile local vars
413
+ * \param msg SIP message
414
+ * \param flags unused
415
+ * \param param unused
416
+ * \return 1
417
+ */
418
+int cb_profile_reset( struct sip_msg *msg, unsigned int flags, void *param )
419
+{
420
+	current_dlg_msg_id = 0;
421
+	current_dlg_msg_pid = 0;
422
+	if (current_pending_linkers) {
423
+		destroy_linkers(current_pending_linkers);
424
+		current_pending_linkers = NULL;
425
+	}
426
+
427
+	/* need to return non-zero - 0 will break the exec of the request */
428
+	return 1;
429
+}
430
+
431
+
432
+/*!
412 433
  * \brief Cleanup a profile
413 434
  * \param msg SIP message
414 435
  * \param flags unused
... ...
@@ -116,6 +116,16 @@ struct dlg_profile_table* search_dlg_profile(str *name);
116 116
 
117 117
 
118 118
 /*!
119
+ * \brief Callback for cleanup of profile local vars
120
+ * \param msg SIP message
121
+ * \param flags unused
122
+ * \param param unused
123
+ * \return 1
124
+ */
125
+int cb_profile_reset( struct sip_msg *msg, unsigned int flags, void *param );
126
+
127
+
128
+/*!
119 129
  * \brief Cleanup a profile
120 130
  * \param msg SIP message
121 131
  * \param flags unused
... ...
@@ -69,6 +69,21 @@ int dlg_cfg_cb(sip_msg_t *msg, unsigned int flags, void *cbp)
69 69
 	return 1;
70 70
 }
71 71
 
72
+int cb_dlg_cfg_reset(sip_msg_t *msg, unsigned int flags, void *cbp)
73
+{
74
+	memset(&_dlg_ctx, 0, sizeof(dlg_ctx_t));
75
+
76
+	return 1;
77
+}
78
+
79
+int cb_dlg_locals_reset(sip_msg_t *msg, unsigned int flags, void *cbp)
80
+{
81
+	LM_DBG("resetting the local dialog shortcuts\n");
82
+	cb_dlg_cfg_reset(msg, flags, cbp);
83
+	cb_profile_reset(msg, flags, cbp);
84
+
85
+	return 1;
86
+}
72 87
 
73 88
 static inline struct dlg_var *new_dlg_var(str *key, str *val)
74 89
 {
... ...
@@ -82,6 +82,8 @@ int pv_get_dlg(sip_msg_t *msg,  pv_param_t *param,
82 82
 int pv_parse_dlg_name(pv_spec_p sp, str *in);
83 83
 
84 84
 int dlg_cfg_cb(sip_msg_t *foo, unsigned int flags, void *bar);
85
+int cb_dlg_cfg_reset(sip_msg_t *msg, unsigned int flags, void *cbp);
86
+int cb_dlg_locals_reset(sip_msg_t *msg, unsigned int flags, void *cbp);
85 87
 
86 88
 void dlg_set_ctx_iuid(dlg_cell_t *dlg);
87 89
 void dlg_reset_ctx_iuid(void);