Commit Graph

13 Commits

Author SHA1 Message Date
Richard Mudgett 69810b306d chan_sip.c: Fix autokillid deadlock potential.
This patch is part of a series to resolve deadlocks in chan_sip.c.

Stopping a scheduled event can result in a deadlock if the scheduled event
is running when you try to stop the event.  If you hold a lock needed by
the scheduled event while trying to stop the scheduled event then a
deadlock can happen.  The general strategy for resolving the deadlock
potential is to push the actual starting and stopping of the scheduled
events off onto the scheduler/do_monitor() thread by scheduling an
immediate one shot scheduled event.  Some restructuring may be needed
because the code may assume that the start/stop of the scheduled events is
immediate.

* Fix clearing autokillid in __sip_autodestruct() even though we could
reschedule.

ASTERISK-25023

Change-Id: I450580dbf26e2e3952ee6628c735b001565c368f
2016-03-16 14:44:51 -05:00
Richard Mudgett cb97198ca6 chan_sip.c: Simplify sip_pvt destructor call levels.
Remove destructor calling destroy_it calling really_destroy_it
for no benefit.  Just make the destructor the really_destroy_it
function.

Change-Id: Idea0d47b27dd74f2488db75bcc7f353d8fdc614a
2016-03-14 14:10:10 -05:00
Corey Farrell d486659502 chan_sip: Simplify dialog/peer references, improve REF_DEBUG output.
* Replace functions for ref/undef of dialogs and peers with macro's
  to call ao2_t_bump/ao2_t_cleanup.
* Enable passthough of REF_DEBUG caller information to sip_alloc and
  find_call.

ASTERISK-24882 #close 
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4189/
........

Merged revisions 433115 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433116 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-19 09:57:59 +00:00
Corey Farrell c08fd275bf Logger: Convert 'struct ast_callid' to unsigned int.
Switch logger callid's from AO2 objects to simple integers.
This helps in two ways.  Copying integers is faster than
referencing AO2 objects, so this will result in a small
reduction in logger overhead.  This also erases the possibility
of an infinate loop caused by an invalid callid in
threadstorage.

ASTERISK-24833 #comment Committed callid conversion to trunk. 
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4466/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432834 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-13 01:12:35 +00:00
Jonathan Rose cd37bec058 logger: Adds additional support for call id logging and chan_sip specific stuff
This patch improves the handling of call id logging significantly with regard
to transfers and adding APIs to better handle specific aspects of logging.
Also, changes have been made to chan_sip in order to better handle the creation
of callids and to enable the monitor thread to bind itself to a particular
call id when a dialog is determined to be related to a callid. It then unbinds
itself before returning to normal monitoring.

review: https://reviewboard.asterisk.org/r/1886/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@366842 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-05-17 16:28:20 +00:00
Alec L Davis 0ccc1f5274 Merged revisions 353321 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/10

................
  r353321 | alecdavis | 2012-01-31 11:16:22 +1300 (Tue, 31 Jan 2012) | 25 lines
  
  Merged revisions 353320 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.8
  
  ........
    r353320 | alecdavis | 2012-01-31 10:57:49 +1300 (Tue, 31 Jan 2012) | 18 lines
    
    RFC3261 Section 8.1.1.5. The sequence number value MUST be expressible as a 32-bit unsigned integer
    
    * fix: use %u instead of %d when dealing with CSeq numbers - to remove possibility of -ve numbers.
    
    * fix: change all uses of seqno and friends (ocseq icseq) from 'int' or 'unsigned int' to uint32_t.
    
    Summary of CSeq numbers.
    An initial CSeq number must be less than 2^31
    A CSeq number can increase in value up to 2^32-1
    An incrementing CSeq number must not wrap around to 0.
    
    Tested with Asterisk 1.8.8.2 with Grandstream phones.
     
    alecdavis (license 585)
    Tested by: alecdavis
     
    Review: https://reviewboard.asterisk.org/r/1699/
  ........
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@353347 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-01-30 22:28:37 +00:00
Russell Bryant 2b2d34b3c9 Constify tag argument in REF_DEBUG related code.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@349409 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-12-31 15:45:57 +00:00
Richard Mudgett b63c1cc545 Fix some potential deadlocks pointed out by helgrind.
* Fixed deadlock potential calling dialog_unlink_all() in
__sip_autodestruct().  Found by helgrind.

* Fixed deadlock potential in handle_request_invite() after calling
sip_new().  Found by helgrind.

* The sip_new() function now returns with the created channel already
locked.

* Removed the dead code that starts a PBX in in sip_new().  No sip_new()
callers caused that code to be executed and it was a bad thing to do
anyway.

* Removed unused parameters and return value from dialog_unlink_all().

* Made dialog_unlink_all() and __sip_autodestruct() safely obtain the
owner and private channel locks without a deadlock avoidance loop.
........

Merged revisions 340284 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 340310 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@340318 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-10-11 19:28:23 +00:00
Terry Wilson b42c6cab17 Revert early destruction of RTP sessions
Some code improperly assumes that the sessions are still there, so revert the
change until I can find all of them and fix them.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@276206 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-07-13 21:42:42 +00:00
Terry Wilson cb160a12b0 Destroy RTP fds when we schedule final dialog destruction
Since we are only keeping the dialog around for retransmissions at this point
and there is no possibility that we are still handling RTP, go ahead and
destroy the RTP sessions. Keeping them alive for 32 past when they are used
is unnecessary and can lead to problems with having too many open file
descriptors, etc.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@275998 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-07-13 17:11:37 +00:00
Mark Michelson cd4ebd336f Add IPv6 to Asterisk.
This adds a generic API for accommodating IPv6 and IPv4 addresses
within Asterisk. While many files have been updated to make use of the
API, chan_sip and the RTP code are the files which actually support
IPv6 addresses at the time of this commit. The way has been paved for
easier upgrading for other files in the near future, though.

Big thanks go to Simon Perrault, Marc Blanchet, and Jean-Philippe Dionne
for their hard work on this.

(closes issue #17565)
Reported by: russell
Patches: 
      asteriskv6-test-report.pdf uploaded by russell (license 2)

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



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@274783 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-07-08 22:08:07 +00:00
David Vossel a1fe641a38 retransmit response to BYE requests until timer J expires
According to RFC 3261 section 17.2.2, which describes non-INVITE server
transaction, when a dialog enters the Completed state it must destroy
the dialog after Timer J (T1*64) fires.  For a BYE transaction Asterisk
terminates the dialog immediately during sip_hangup() when it should be
waiting T1*64 ms.  This results in some odd behavior.  For instance if
Asterisk receives a BYE and transmits a 200ok in response, if the endpoint
never receives the 200ok it will retransmit the BYE to which Asterisk
responds with a "481 Call leg/transaction does not exist" because the
dialog is already gone.

To resolve this I made a function called sip_scheddestroy_final().  This
differs slightly from sip_schedestroy() in that it enables a flag that
will prevent the destruction from ever being rescheduled or canceled
afterwards.  It also prevents the pvt's needdestroy flag from being set
which triggers the destruction of the dialog within the do_monitor thread().
By using this function we are guaranteed destruction will not occur
until the scheduled time.  This allows Asterisk to respond to any possible
retransmits for a dialog after we process the initial BYE request for T1*64 ms.

Other changes: I removed two instances where sip_cancel_destroy is used
right before calling sip_scheddestroy.  sip_scheddestroy always calls
sip_cancel_destroy before scheduling the new destruction so it is completely
unnecessary.

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



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@271262 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-06-17 18:45:32 +00:00
Tilghman Lesher e7a5fb5459 Make all of the various rtpqos parameters in this branch available from the CHANNEL function.
Also includes a test for retrieving rtpqos parameters, including a NULL RTP
driver.  Additionally, some further separation of the SIP internal API into
headers was necessary.

(closes issue #16652)
 Reported by: kkm
 Patches: 
       20100204__issue16652.diff.txt uploaded by tilghman (license 14)
 
Review: https://reviewboard.asterisk.org/r/501/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@247124 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-17 06:25:15 +00:00