[asterisk-commits] file: trunk r42087 - in /trunk: ./ channels/chan_iax2.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Sep 6 08:58:21 MST 2006


Author: file
Date: Wed Sep  6 10:58:21 2006
New Revision: 42087

URL: http://svn.digium.com/view/asterisk?rev=42087&view=rev
Log:
Merged revisions 42086 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r42086 | file | 2006-09-06 11:55:20 -0400 (Wed, 06 Sep 2006) | 2 lines

Make realtime regseconds work as people expected (0 on registration expiration or release, and actual on normal state) (issue #7684 reported by kshumard)

........

Modified:
    trunk/   (props changed)
    trunk/channels/chan_iax2.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?rev=42087&r1=42086&r2=42087&view=diff
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Wed Sep  6 10:58:21 2006
@@ -2550,14 +2550,12 @@
 	return user;
 }
 
-static void realtime_update_peer(const char *peername, struct sockaddr_in *sin)
+static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, time_t regtime)
 {
 	char port[10];
 	char regseconds[20];
-	time_t nowtime;
 	
-	time(&nowtime);
-	snprintf(regseconds, sizeof(regseconds), "%d", (int)nowtime);
+	snprintf(regseconds, sizeof(regseconds), "%d", (int)regtime);
 	snprintf(port, sizeof(port), "%d", ntohs(sin->sin_port));
 	ast_update_realtime("iaxpeers", "name", peername, 
 		"ipaddr", ast_inet_ntoa(sin->sin_addr), "port", port, 
@@ -5487,6 +5485,8 @@
 		return;
 
 	ast_log(LOG_DEBUG, "Expiring registration for peer '%s'\n", p->name);
+	if (ast_test_flag((&globalflags), IAX_RTUPDATE) && (ast_test_flag(p, IAX_TEMPONLY|IAX_RTCACHEFRIENDS)))
+		realtime_update_peer(p->name, &p->addr, 0);
 	manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: IAX2/%s\r\nPeerStatus: Unregistered\r\nCause: Expired\r\n", p->name);
 	/* Reset the address */
 	memset(&p->addr, 0, sizeof(p->addr));
@@ -5571,8 +5571,15 @@
 		return -1;
 	}
 
-	if (ast_test_flag((&globalflags), IAX_RTUPDATE) && (ast_test_flag(p, IAX_TEMPONLY|IAX_RTCACHEFRIENDS)))
-		realtime_update_peer(name, sin);
+	if (ast_test_flag((&globalflags), IAX_RTUPDATE) && (ast_test_flag(p, IAX_TEMPONLY|IAX_RTCACHEFRIENDS))) {
+		if (sin->sin_addr.s_addr) {
+			time_t nowtime;
+			time(&nowtime);
+			realtime_update_peer(name, sin, nowtime);
+		} else {
+			realtime_update_peer(name, sin, 0);
+		}
+	}
 	if (inaddrcmp(&p->addr, sin)) {
 		if (iax2_regfunk)
 			iax2_regfunk(p->name, 1);



More information about the asterisk-commits mailing list