[Home]

Summary:ASTERISK-16286: [patch] Realtime erase username when Unavailable
Reporter:Ricardo Landim (ricardolandim)Labels:
Date Opened:2010-06-24 06:42:47Date Closed:2010-09-14 14:29:45
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/Registration
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) chan_sip.patch
( 1) reg-expiry-username-1.4-fix1.diff
( 2) reg-expiry-username-1.6.2-fix1.diff
( 3) reg-expiry-username-1.8-fix1.diff
( 4) reg-expiry-username-trunk-fix1.diff
Description:When an extension sip become unavailable, the realtime clears the username within the database. Logs below:

res_config_mysql.c: MySQL RealTime: Update SQL: UPDATE sip SET fullcontact = '', ipaddr = '', port = '', regseconds = '0', username = '', regserver = '' WHERE name = '341400'

The right would be (without username column):

res_config_mysql.c: MySQL RealTime: Update SQL: UPDATE sip SET fullcontact = '', ipaddr = '', port = '', regseconds = '0', regserver = '' WHERE name = '341400'

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

[Jun 24 08:31:08] DEBUG[11873] res_config_mysql.c: MySQL RealTime: Update SQL: UPDATE sip SET fullcontact = '', ipaddr = '', port = '', regseconds = '0', username = '', regserver = '' WHERE name = '341400'
[Jun 24 08:31:08] DEBUG[11873] res_config_mysql.c: MySQL RealTime: Update SQL: UPDATE sip SET lastms = '' WHERE name = '341400'
[Jun 24 08:31:08] DEBUG[11873] devicestate.c: Notification of state change to be queued on device/channel SIP/341400
[Jun 24 08:31:08] DEBUG[11854] chan_sip.c: Checking device state for peer 341400
[Jun 24 08:31:08] DEBUG[11854] devicestate.c: Changing state for SIP/341400 - state 5 (Unavailable)
Comments:By: Paul Belanger (pabelanger) 2010-06-24 07:51:52

Are you able to provide a patch?

By: Ricardo Landim (ricardolandim) 2010-06-24 08:47:10

yes... the patch (comment username data):

--- chan_sip.c  2010-06-18 15:41:04.000000000 -0300
+++ chan_sip.c  2010-06-24 10:43:32.000000000 -0300
@@ -2543,11 +2543,11 @@
       if (fc)
               ast_update_realtime("sippeers", "name", peername, "ipaddr", ipaddr,
                       "port", port, "regseconds", regseconds, "useragent", useragent,
-                       "username", username, fc, fullcontact, syslabel, sysname, NULL); /* note fc and syslabel _can_ be NULL */
+                       /*"username", username,*/ fc, fullcontact, syslabel, sysname, NULL); /* note fc and syslabel _can_ be NULL */
       else
               ast_update_realtime("sippeers", "name", peername, "ipaddr", ipaddr,
                       "port", port, "regseconds", regseconds, "useragent", useragent,
-                       "username", username, syslabel, sysname, NULL); /* note syslabel _can_ be NULL */
+                       /*"username", username,*/ syslabel, sysname, NULL); /* note syslabel _can_ be NULL */
       if (seen_lastms) {
               /* We cannot do this in the same statement as above, because the lack of
                * this field could cause the whole statement to fail. */

By: Ricardo Landim (ricardolandim) 2010-06-24 08:50:40

this patch remove the username update!

By: Ricardo Landim (ricardolandim) 2010-06-24 08:53:22

need to check that this change does not affect other system functions!

By: Ricardo Landim (ricardolandim) 2010-06-24 08:54:37

Look my database (username changed)

+--------+----------+
| name   | username |
+--------+----------+
| 212100 | s        |
| 150300 | 3000     |
| 321097 | s        |
| 100553 | s        |
+--------+----------+

By: Matthew Nicholson (mnicholson) 2010-08-13 11:52:24

What version of asterisk are you running?  I want to upload a patch for you to test.

By: Matthew Nicholson (mnicholson) 2010-08-13 15:28:57

I may be missing something, but I don't understand why this is a bug.  Please explain why you think this is a bug.

By: Matthew Nicholson (mnicholson) 2010-08-24 11:50:43

Upon further review, It appears that the username is used when sending an INVITE to a non registered peer.  I am uploading patches (one for each supported asterisk version) that should preserve the username when a peer becomes unavailable.  Please test with the appropriate patch for your asterisk version and let me know if it works for you.



By: Matthew Nicholson (mnicholson) 2010-09-14 14:09:39

Any updates on this?

By: Ricardo Landim (ricardolandim) 2010-09-14 14:12:10

ok.... the patch works! The username is not changed!

By: Matthew Nicholson (mnicholson) 2010-09-14 14:22:08

Ok, I'll get this committed.

By: Digium Subversion (svnbot) 2010-09-14 14:26:19

Repository: asterisk
Revision: 286756

U   branches/1.4/channels/chan_sip.c

------------------------------------------------------------------------
r286756 | mnicholson | 2010-09-14 14:26:19 -0500 (Tue, 14 Sep 2010) | 13 lines

Don't clear the username from a realtime database when a registration expires.

Non-realtime chan_sip does not clear the username from memory when a registration expiries so realtime probably shouldn't either.

(closes issue ASTERISK-16286)
Reported by: ricardolandim
Patches:
     reg-expiry-username-1.4-fix1.diff uploaded by mnicholson (license 96)
     reg-expiry-username-1.6.2-fix1.diff uploaded by mnicholson (license 96)
     reg-expiry-username-1.8-fix1.diff uploaded by mnicholson (license 96)
     reg-expiry-username-trunk-fix1.diff uploaded by mnicholson (license 96)
Tested by: ricardolandim, mnicholson

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

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

By: Digium Subversion (svnbot) 2010-09-14 14:27:29

Repository: asterisk
Revision: 286757

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

------------------------------------------------------------------------
r286757 | mnicholson | 2010-09-14 14:27:29 -0500 (Tue, 14 Sep 2010) | 20 lines

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

........
 r286756 | mnicholson | 2010-09-14 14:26:18 -0500 (Tue, 14 Sep 2010) | 13 lines
 
 Don't clear the username from a realtime database when a registration expires.
 
 Non-realtime chan_sip does not clear the username from memory when a registration expiries so realtime probably shouldn't either.
 
 (closes issue ASTERISK-16286)
 Reported by: ricardolandim
 Patches:
       reg-expiry-username-1.4-fix1.diff uploaded by mnicholson (license 96)
       reg-expiry-username-1.6.2-fix1.diff uploaded by mnicholson (license 96)
       reg-expiry-username-1.8-fix1.diff uploaded by mnicholson (license 96)
       reg-expiry-username-trunk-fix1.diff uploaded by mnicholson (license 96)
 Tested by: ricardolandim, mnicholson
........

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

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

By: Digium Subversion (svnbot) 2010-09-14 14:28:38

Repository: asterisk
Revision: 286758

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

------------------------------------------------------------------------
r286758 | mnicholson | 2010-09-14 14:28:38 -0500 (Tue, 14 Sep 2010) | 27 lines

Merged revisions 286757 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2

................
 r286757 | mnicholson | 2010-09-14 14:27:28 -0500 (Tue, 14 Sep 2010) | 20 lines
 
 Merged revisions 286756 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4
 
 ........
   r286756 | mnicholson | 2010-09-14 14:26:18 -0500 (Tue, 14 Sep 2010) | 13 lines
   
   Don't clear the username from a realtime database when a registration expires.
   
   Non-realtime chan_sip does not clear the username from memory when a registration expiries so realtime probably shouldn't either.
   
   (closes issue ASTERISK-16286)
   Reported by: ricardolandim
   Patches:
         reg-expiry-username-1.4-fix1.diff uploaded by mnicholson (license 96)
         reg-expiry-username-1.6.2-fix1.diff uploaded by mnicholson (license 96)
         reg-expiry-username-1.8-fix1.diff uploaded by mnicholson (license 96)
         reg-expiry-username-trunk-fix1.diff uploaded by mnicholson (license 96)
   Tested by: ricardolandim, mnicholson
 ........
................

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

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

By: Digium Subversion (svnbot) 2010-09-14 14:29:44

Repository: asterisk
Revision: 286759

_U  trunk/
U   trunk/channels/chan_sip.c

------------------------------------------------------------------------
r286759 | mnicholson | 2010-09-14 14:29:44 -0500 (Tue, 14 Sep 2010) | 34 lines

Merged revisions 286758 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

................
 r286758 | mnicholson | 2010-09-14 14:28:38 -0500 (Tue, 14 Sep 2010) | 27 lines
 
 Merged revisions 286757 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.6.2
 
 ................
   r286757 | mnicholson | 2010-09-14 14:27:28 -0500 (Tue, 14 Sep 2010) | 20 lines
   
   Merged revisions 286756 via svnmerge from
   https://origsvn.digium.com/svn/asterisk/branches/1.4
   
   ........
     r286756 | mnicholson | 2010-09-14 14:26:18 -0500 (Tue, 14 Sep 2010) | 13 lines
     
     Don't clear the username from a realtime database when a registration expires.
     
     Non-realtime chan_sip does not clear the username from memory when a registration expiries so realtime probably shouldn't either.
     
     (closes issue ASTERISK-16286)
     Reported by: ricardolandim
     Patches:
           reg-expiry-username-1.4-fix1.diff uploaded by mnicholson (license 96)
           reg-expiry-username-1.6.2-fix1.diff uploaded by mnicholson (license 96)
           reg-expiry-username-1.8-fix1.diff uploaded by mnicholson (license 96)
           reg-expiry-username-trunk-fix1.diff uploaded by mnicholson (license 96)
     Tested by: ricardolandim, mnicholson
   ........
 ................
................

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

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