]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res_pjsip_session: Fix double re-INVITE collision crash. 41/1041/1
authorRichard Mudgett <rmudgett@digium.com>
Fri, 13 Feb 2015 17:21:28 +0000 (17:21 +0000)
committerMark Michelson <mmichelson@digium.com>
Wed, 5 Aug 2015 21:19:00 +0000 (16:19 -0500)
commitf6dcbd9707eef32af106c64beca41ac1388b424b
tree2fd70c22a033879bf68bf82b596d2bb8ccc06850
parent4350fd22c8750028d21d998eff7c94e985a658b4
res_pjsip_session: Fix double re-INVITE collision crash.

A multi-asterisk box setup with direct media enabled would occasionally
crash when two re-INVITE collisions on a call leg happen in a row.

The re-INVITE logic only had one timer struct to defer the re-INVITE.
When the second collision happens the timer struct is overwritten and put
into the timer heap again.  Resources for the first timer are leaked and
the heap has two positions occupied by the same timer struct.  Now the
heap ordering is potentially corrupted, the timer will fire twice, and any
resources allocated for the second timer will be released twice.

* The solution is to put the collided re-INVITE into the delayed requests
queue with all the other delayed requests and cherry pick the next request
that can come off the queue when an event happens.

* Changed to put delayed BYE requests at the head of the delayed queue.
There is no sense in processing delayed UPDATEs and re-INVITEs when a BYE
has been requested.

* Made the start of a BYE request flush the delayed requests queue to
prevent a delayed request from overlapping the BYE transaction.  I saw a
few cases where a delayed re-INVITE got started after the BYE transaction
started.

* Changed the delayed_request struct to use an enum instead of a string
for the request method.  Cherry picking the queue is easier with an enum
than string comparisons and the compiler can warn if a switch statement
does not cover all defined enum values.

* Improved the debug output to give more information.  It helps to know
which channel is involved with an endpoint.  Trunks can have many channels
associated with the endpoint at the same time.

ASTERISK-24727 #close
Reported by: Mark Michelson

Review: https://reviewboard.asterisk.org/r/4414/

Change-Id: Ib05700c3a13ceac53b17d66099ef0d296a5e1863
res/res_pjsip_session.c