[Asterisk-code-review] pjproject_bundled: Fixed deadlock between SIP transaction and dialog (asterisk[20])
Stanislav Abramenkov
asteriskteam at digium.com
Fri Apr 14 00:11:15 CDT 2023
Stanislav Abramenkov has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/20069 )
Change subject: pjproject_bundled: Fixed deadlock between SIP transaction and dialog
......................................................................
pjproject_bundled: Fixed deadlock between SIP transaction and dialog
ASTERISK-29286
Change-Id: Iac7972d8e0a4b10db88335dd170d818571fdc814
---
A third-party/pjproject/patches/0012-Fixed-deadlock-between-SIP-transaction-and-dialog.patch
1 file changed, 70 insertions(+), 0 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/69/20069/1
diff --git a/third-party/pjproject/patches/0012-Fixed-deadlock-between-SIP-transaction-and-dialog.patch b/third-party/pjproject/patches/0012-Fixed-deadlock-between-SIP-transaction-and-dialog.patch
new file mode 100644
index 0000000..769423c
--- /dev/null
+++ b/third-party/pjproject/patches/0012-Fixed-deadlock-between-SIP-transaction-and-dialog.patch
@@ -0,0 +1,59 @@
+From 72b46f74dd17b31815d4a0a19898bd2b425b45b3 Mon Sep 17 00:00:00 2001
+From: sauwming <ming at teluu.com>
+Date: Fri, 14 Apr 2023 12:22:10 +0800
+Subject: [PATCH] Fixed deadlock between SIP transaction and dialog (#3492)
+
+---
+ pjsip/src/pjsip/sip_transaction.c | 18 ++++++++++++------
+ 1 file changed, 12 insertions(+), 6 deletions(-)
+
+diff --git a/pjsip/src/pjsip/sip_transaction.c b/pjsip/src/pjsip/sip_transaction.c
+index 0c9f1b50f..87edf0a04 100644
+--- a/pjsip/src/pjsip/sip_transaction.c
++++ b/pjsip/src/pjsip/sip_transaction.c
+@@ -143,6 +143,7 @@ enum
+ {
+ NO_NOTIFY = 1,
+ NO_SCHEDULE_HANDLER = 2,
++ RELEASE_LOCK = 4
+ };
+
+ /* Prototypes. */
+@@ -1330,16 +1331,18 @@ static void tsx_set_state( pjsip_transaction *tsx,
+ * 3. tsx_shutdown() hasn't been called.
+ * Refer to ticket #2001 (https://github.com/pjsip/pjproject/issues/2001).
+ */
+- if (event_src_type == PJSIP_EVENT_TIMER &&
+- (pj_timer_entry *)event_src == &tsx->timeout_timer)
++ if ((flag & RELEASE_LOCK) != 0 ||
++ (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)
++ if ((flag & RELEASE_LOCK) != 0 ||
++ (event_src_type == PJSIP_EVENT_TIMER &&
++ (pj_timer_entry *)event_src == &tsx->timeout_timer))
+ {
+ pj_grp_lock_acquire(tsx->grp_lock);
+ }
+@@ -2044,9 +2047,12 @@ static void send_msg_callback( pjsip_send_state *send_state,
+ if (tsx->state != PJSIP_TSX_STATE_TERMINATED &&
+ tsx->state != PJSIP_TSX_STATE_DESTROYED)
+ {
+- tsx_set_state( tsx, PJSIP_TSX_STATE_TERMINATED,
++ /* Set tsx state to TERMINATED, but release the lock
++ * when invoking the callback, to avoid deadlock.
++ */
++ tsx_set_state( tsx, PJSIP_TSX_STATE_TERMINATED,
+ PJSIP_EVENT_TRANSPORT_ERROR,
+- send_state->tdata, 0);
++ send_state->tdata, RELEASE_LOCK);
+ }
+ /* Don't forget to destroy if we have pending destroy flag
+ * (https://github.com/pjsip/pjproject/issues/906)
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/20069
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 20
Gerrit-Change-Id: Iac7972d8e0a4b10db88335dd170d818571fdc814
Gerrit-Change-Number: 20069
Gerrit-PatchSet: 1
Gerrit-Owner: Stanislav Abramenkov <stas.abramenkov at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20230414/69c662d4/attachment-0001.html>
More information about the asterisk-code-review
mailing list