From 23a298f28c6bb9c3957e1b3d76b4a19407eeb874 Mon Sep 17 00:00:00 2001 From: Jonathan Rose Date: Mon, 10 Sep 2012 21:15:38 +0000 Subject: [PATCH] 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/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@372808 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_sip.c | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 8fc808448b..69efc066a2 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -545,6 +545,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") Qualify a SIP peer. + + SIPqualifypeerdone + @@ -18957,18 +18960,47 @@ static char *_sip_qualify_peer(int type, int fd, struct mansession *s, const str 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 + + Raised when SIPqualifypeer has finished qualifying the specified peer. + + + The name of the peer. + + + This is only included if an ActionID Header was sent with the action request, in which case it will be that ActionID. + + + + SIPqualifypeer + + + ***/ + 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;