summaryrefslogtreecommitdiff
path: root/third-party/pjproject/patches/0035-r5572-svn-backport-dialog-transaction-deadlock.patch
blob: 0c5e9866c2aef37d970a640f05d730e73d75812d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Index: trunk/pjsip/src/pjsip/sip_transaction.c
===================================================================
--- a/pjsip/src/pjsip/sip_transaction.c	(revision 5244)
+++ b/pjsip/src/pjsip/sip_transaction.c	(revision 5572)
@@ -1231,5 +1231,27 @@
 	PJSIP_EVENT_INIT_TSX_STATE(e, tsx, event_src_type, event_src,
 				   prev_state);
+
+	/* For timer event, release lock to avoid deadlock.
+	 * This should be safe because:
+	 * 1. The tsx state just switches to TERMINATED or DESTROYED.
+  	 * 2. There should be no other processing taking place. All other
+  	 *    events, such as the ones handled by tsx_on_state_terminated()
+  	 *    should be ignored.
+         * 3. tsx_shutdown() hasn't been called.
+	 * Refer to ticket #2001 (https://trac.pjsip.org/repos/ticket/2001).
+	 */
+	if (event_src_type == PJSIP_EVENT_TIMER &&
+	    (pj_timer_entry *)event_src == &tsx->timeout_timer)
+	{
+	    pj_grp_lock_release(tsx->grp_lock);
+	}
+
 	(*tsx->tsx_user->on_tsx_state)(tsx, &e);
+
+	if (event_src_type == PJSIP_EVENT_TIMER &&
+	    (pj_timer_entry *)event_src == &tsx->timeout_timer)
+	{
+	    pj_grp_lock_acquire(tsx->grp_lock);
+	}
     }