Bläddra i källkod

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
Daniel-Constantin Mierla 11 år sedan
förälder
incheckning
c125cf6f36
3 ändrade filer med 10 tillägg och 2 borttagningar
  1. 2 0
      modules/dialog/dlg_handlers.c
  2. 7 2
      modules/dialog/dlg_var.c
  3. 1 0
      modules/dialog/dlg_var.h

+ 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"
@@ -874,6 +875,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;