Pārlūkot izejas kodu

dialog: release of dialog for not-forwarded initial request done by creator

- avoid releasing new dialog in case of upstream paralel forking
  or retransmission by other processes than the other which created the
  dialog
- it could result in destroying the dialog in initial state if the
  request was not forwarded yet, likely to happen because creator
  process runs more callbacks

(cherry picked from commit c125cf6f36aedb75b4f1e0b32dbe5bdd0a48b8b5)
(cherry picked from commit be02c48d9335dc71a023244d20ef669f4e986e9e)
Daniel-Constantin Mierla 11 gadi atpakaļ
vecāks
revīzija
746bb972a1

+ 2 - 0
modules/dialog/dlg_handlers.c

@@ -58,6 +58,7 @@
 #include "../../lib/kcore/statistics.h"
 #include "../../action.h"
 #include "../../script_cb.h"
+#include "../../pt.h"
 #include "../../lib/kcore/faked_msg.h"
 #include "../../parser/parse_from.h"
 #include "../../parser/parse_cseq.h"
@@ -873,6 +874,7 @@ int dlg_new_dialog(sip_msg_t *req, struct cell *t, const int run_initial_cbs)
 
     if_update_stat( dlg_enable_stats, processed_dlgs, 1);
 
+	_dlg_ctx.cpid = my_pid();
 finish:
     _dlg_ctx.iuid.h_entry = dlg->h_entry;
     _dlg_ctx.iuid.h_id = dlg->h_id;

+ 7 - 2
modules/dialog/dlg_var.c

@@ -46,9 +46,14 @@ int dlg_cfg_cb(sip_msg_t *msg, unsigned int flags, void *cbp)
 		dlg = dlg_get_ctx_dialog();
 		if(dlg!=NULL) {
 			if(_dlg_ctx.t==0 && dlg->state==DLG_STATE_UNCONFIRMED) {
-				LM_DBG("new dialog with no trasaction after config execution\n");
-				dlg_release(dlg);
+				if(_dlg_ctx.cpid!=0 && _dlg_ctx.cpid==my_pid()) {
+					/* release to destroy dialog if created by this process
+					 * and request was not forwarded */
+					LM_DBG("new dialog with no trasaction after config execution\n");
+					dlg_release(dlg);
+				}
 			}
+			/* get ctx dlg increased ref count - release now */
 			dlg_release(dlg);
 		}
 	}

+ 1 - 0
modules/dialog/dlg_var.h

@@ -39,6 +39,7 @@ typedef struct _dlg_ctx {
 	int timeout;
 	dlg_cell_t *dlg1;
 	dlg_iuid_t iuid;
+	int cpid;
 	int set;
 	unsigned int dir;
 	int t;