[svn-commits] jrose: trunk r372808 - /trunk/channels/chan_sip.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Sep 10 16:15:44 CDT 2012


Author: jrose
Date: Mon Sep 10 16:15:38 2012
New Revision: 372808

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=372808
Log:
chan_sip: Change SIPQualifyPeer to improve initial response time

Prior to this patch, The acknowledgement wasn't produced until after
executing the sip_poke_peer action actually responsible for
qualifying the peer. Now the response is given immediately once it is
known that a peer will be qualified and a SIPqualifypeerdone event
is issued when the process is finished. Thanks to OEJ for identifying
the problem and helping to come up with a solution.

(issue AST-969)
Reported by John Bigelow
Review: https://reviewboard.asterisk.org/r/2098/

Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=372808&r1=372807&r2=372808
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Mon Sep 10 16:15:38 2012
@@ -545,6 +545,9 @@
 		<description>
 			<para>Qualify a SIP peer.</para>
 		</description>
+		<see-also>
+			<ref type="managerEvent">SIPqualifypeerdone</ref>
+		</see-also>
 	</manager>
 	<manager name="SIPshowregistry" language="en_US">
 		<synopsis>
@@ -18957,18 +18960,47 @@
 
 	load_realtime = (argc == 5 && !strcmp(argv[4], "load")) ? TRUE : FALSE;
 	if ((peer = sip_find_peer(argv[3], NULL, load_realtime, FINDPEERS, FALSE, 0))) {
+
+		const char *id = astman_get_header(m,"ActionID");
+		char idText[256] = "";
+
+		if (type != 0) {
+			astman_send_ack(s, m, "SIP peer found - will qualify");
+		}
+
+		if (!ast_strlen_zero(id)) {
+			snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
+		}
+
 		sip_poke_peer(peer, 1);
+
+		/*** DOCUMENTATION
+			<managerEventInstance>
+				<synopsis>Raised when SIPqualifypeer has finished qualifying the specified peer.</synopsis>
+				<syntax>
+					<parameter name="Peer">
+						<para>The name of the peer.</para>
+					</parameter>
+					<parameter name="ActionID">
+						<para>This is only included if an ActionID Header was sent with the action request, in which case it will be that ActionID.</para>
+					</parameter>
+				</syntax>
+				<see-also>
+					<ref type="manager">SIPqualifypeer</ref>
+				</see-also>
+			</managerEventInstance>
+		***/
+		manager_event(EVENT_FLAG_CALL, "SIPqualifypeerdone",
+			"Peer: %s\r\n"
+			"%s",
+			argv[3],
+			idText);
+
 		sip_unref_peer(peer, "qualify: done with peer");
 	} else if (type == 0) {
 		ast_cli(fd, "Peer '%s' not found\n", argv[3]);
-		return CLI_SUCCESS;
 	} else {
 		astman_send_error(s, m, "Peer not found");
-		return CLI_SUCCESS;
-	}
-
-	if (type != 0) {
-		astman_send_ack(s, m, "Qualify Peer successful");
 	}
 
 	return CLI_SUCCESS;




More information about the svn-commits mailing list