Opened 11 years ago

Closed 10 years ago

#1628 closed enhancement (fixed)

Modify SIP transaction to use group lock to avoid deadlock etc.

Reported by: bennylp Owned by: bennylp
Priority: normal Milestone: release-2.2
Component: pjsip Version: trunk
Keywords: Cc:
Backport to 1.x milestone: Backported: no

Description

The proxy use case of PJSIP will introduce deadlock and other racing condition when using the transaction. Consider the following case:

Thread 1:

  • UAC side receives response and is forwarding it to UAS transaction

Thread 2:

  • UAS gets transport disconnection event and instructing UAC to CANCEL

Also there is a synchronization issue where a transaction is holding a stale pointer to the other transaction.

These problems can be solved by changing the transaction to use the Group Lock (introduced in PJSIP 2.1) and arrange the usage as follows:

  1. Create the UAC transaction by specifying UAS's group lock as the group lock to use.
  2. This way, both transactions will be using the same lock which will prevent deadlock.
  3. The transactions also make use of the reference counting mechanism of the group lock. This way, both transactions will be destroyed simultaneously ONLY when both have indicated that they can be destroyed. This will prevent the stale pointer problem.

Thank you Mike Evans for reporting the problem and volunteering to test the initial patch.

Change History (2)

comment:1 Changed 11 years ago by bennylp

In 4420:

Implementation of Re #1628: Modify SIP transaction to use group lock to avoid deadlock etc.

comment:2 Changed 10 years ago by bennylp

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.