[Home]

Summary:ASTERISK-15614: [patch] chan_sip does not decrease module refcount on deferred BYE
Reporter:Ben Winslow (rain)Labels:
Date Opened:2010-02-11 14:35:26.000-0600Date Closed:2010-06-22 12:37:26
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) chan_sip-unref-fix.diff
Description:When sip_hangup clears a channel with SIP_DEFER_BYE_ON_TRANSFER set, it will return without calling ast_module_unref().  This causes the use counter for chan_sip to increase over time, making it impossible to unload the module without restarting Asterisk.

The attached patch calls ast_module_unref() immediately before returning in the deferred BYE case.  I believe this is safe, because the SIP dialog involved will still be freed when the containing AO2 object's refcount hits 0 as part of module_unload.


****** STEPS TO REPRODUCE ******

Observe chan_sip's use count after a call transfer that causes SIP_DEFER_BYE_ON_TRANSFER to be set.

****** ADDITIONAL INFORMATION ******

This bug exists all the way back to 1.4.x, and I believe the same fix is safe there without leaking memory; however, I haven't looked at that code as hard so I'm not 100% sure.
Comments:By: Leif Madsen (lmadsen) 2010-02-17 13:34:21.000-0600

Thanks for the contribution!

By: Ben Winslow (rain) 2010-05-04 14:34:29

I've been testing this patch for a few months now, and although I haven't had to unload chan_sip many times during that period, I've had no issues and my refcount currently matches the number of SIP channels in use.

By: Digium Subversion (svnbot) 2010-06-22 12:31:57

Repository: asterisk
Revision: 271902

U   branches/1.4/channels/chan_sip.c

------------------------------------------------------------------------
r271902 | mnicholson | 2010-06-22 12:31:56 -0500 (Tue, 22 Jun 2010) | 8 lines

Decrease the module ref count in sip_hangup when SIP_DEFER_BYE_ON_TRANSFER is set.  This is necessary to keep the ref count correct.

(closes issue ASTERISK-15614)
Reported by: rain
Patches:
     chan_sip-unref-fix.diff uploaded by rain (license 327)
Tested by: rain

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=271902

By: Digium Subversion (svnbot) 2010-06-22 12:32:37

Repository: asterisk
Revision: 271902

U   branches/1.4/channels/chan_sip.c

------------------------------------------------------------------------
r271902 | mnicholson | 2010-06-22 12:31:57 -0500 (Tue, 22 Jun 2010) | 8 lines

Decrease the module ref count in sip_hangup when SIP_DEFER_BYE_ON_TRANSFER is set.  This is necessary to keep the ref count correct.

(closes issue ASTERISK-15614)
Reported by: rain
Patches:
     chan_sip-unref-fix.diff uploaded by rain (license 327) (modified)
Tested by: rain

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=271902

By: Digium Subversion (svnbot) 2010-06-22 12:35:17

Repository: asterisk
Revision: 271903

_U  trunk/
U   trunk/channels/chan_sip.c

------------------------------------------------------------------------
r271903 | mnicholson | 2010-06-22 12:35:16 -0500 (Tue, 22 Jun 2010) | 15 lines

Merged revisions 271902 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
 r271902 | mnicholson | 2010-06-22 12:31:57 -0500 (Tue, 22 Jun 2010) | 8 lines
 
 Decrease the module ref count in sip_hangup when SIP_DEFER_BYE_ON_TRANSFER is set.  This is necessary to keep the ref count correct.
 
 (closes issue ASTERISK-15614)
 Reported by: rain
 Patches:
       chan_sip-unref-fix.diff uploaded by rain (license 327) (modified)
 Tested by: rain
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=271903

By: Digium Subversion (svnbot) 2010-06-22 12:37:26

Repository: asterisk
Revision: 271904

_U  branches/1.6.2/
U   branches/1.6.2/channels/chan_sip.c

------------------------------------------------------------------------
r271904 | mnicholson | 2010-06-22 12:37:25 -0500 (Tue, 22 Jun 2010) | 22 lines

Merged revisions 271903 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
 r271903 | mnicholson | 2010-06-22 12:35:17 -0500 (Tue, 22 Jun 2010) | 15 lines
 
 Merged revisions 271902 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4
 
 ........
   r271902 | mnicholson | 2010-06-22 12:31:57 -0500 (Tue, 22 Jun 2010) | 8 lines
   
   Decrease the module ref count in sip_hangup when SIP_DEFER_BYE_ON_TRANSFER is set.  This is necessary to keep the ref count correct.
   
   (closes issue ASTERISK-15614)
   Reported by: rain
   Patches:
         chan_sip-unref-fix.diff uploaded by rain (license 327) (modified)
   Tested by: rain
 ........
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=271904