[Asterisk-code-review] res pjsip distributor: Get a reference to dialog serializer. (asterisk[certified/13.1])

Mark Michelson asteriskteam at digium.com
Fri Sep 18 09:44:28 CDT 2015


Mark Michelson has uploaded a new change for review.

  https://gerrit.asterisk.org/1286

Change subject: res_pjsip_distributor: Get a reference to dialog serializer.
......................................................................

res_pjsip_distributor: Get a reference to dialog serializer.

There have been crashes seen where a taskprocessor's listener is NULL
unexpectedly.

Looking at backtraces, the problem was specifically seen in PJSIP
serializers.

The distributor code grabs the dialog that the incoming message belongs
to. From there, the distributor gets the serializer off the dialog in
order to distribute the task. The problem is that the distributor only
gets a bare pointer to the serializer rather than a reference. The
result is that between when the distributor gets its pointer and when
the task is pushed to the serializer, the serializer may get destroyed.

The fix for this is to have the distributor grab a reference to the
taskprocessor instead of a bare pointer.

Change-Id: I14563093f8320f79063b65792461f18f06c07a77
---
M res/res_pjsip/pjsip_distributor.c
1 file changed, 2 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/86/1286/1

diff --git a/res/res_pjsip/pjsip_distributor.c b/res/res_pjsip/pjsip_distributor.c
index 90744fd..7f179a5 100644
--- a/res/res_pjsip/pjsip_distributor.c
+++ b/res/res_pjsip/pjsip_distributor.c
@@ -171,7 +171,7 @@
 	if (dlg) {
 		dist = pjsip_dlg_get_mod_data(dlg, distributor_mod.id);
 		if (dist) {
-			serializer = dist->serializer;
+			serializer = ao2_bump(dist->serializer);
 		}
 	}
 
@@ -195,6 +195,7 @@
 	if (dlg) {
 		pjsip_dlg_dec_lock(dlg);
 	}
+	ast_taskprocessor_unreference(serializer);
 
 	return PJ_TRUE;
 }

-- 
To view, visit https://gerrit.asterisk.org/1286
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I14563093f8320f79063b65792461f18f06c07a77
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: certified/13.1
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-code-review mailing list