From c26ccb97b990c0a0af45dc1a3188bdf42b9dc8a7 Mon Sep 17 00:00:00 2001 From: Luigi Rizzo <rizzo@icir.org> Date: Mon, 13 Nov 2006 14:14:54 +0000 Subject: [PATCH] merge from codename-pineapple and astobj2 47499: simplify __sip_ack() removing a strcmp for looking up packets. no functional change, only performance, so don't need to merging to earlier branches now. Approved By: oej git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@47538 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_sip.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 1dd26d9534..243d139f46 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2062,38 +2062,33 @@ static void sip_cancel_destroy(struct sip_pvt *p) static void __sip_ack(struct sip_pvt *p, int seqno, int resp, int sipmethod) { struct sip_pkt *cur, *prev = NULL; - - /* Just in case... */ - char *msg; - int res = FALSE; - - msg = sip_methods[sipmethod].text; + const char *msg = "Not Found"; /* used only for debugging */ sip_pvt_lock(p); for (cur = p->packets; cur; prev = cur, cur = cur->next) { - if ((cur->seqno == seqno) && ((ast_test_flag(cur, FLAG_RESPONSE)) == resp) && - ((ast_test_flag(cur, FLAG_RESPONSE)) || - (!strncasecmp(msg, cur->data, strlen(msg)) && (cur->data[strlen(msg)] < 33)))) { + if (cur->seqno != seqno || ast_test_flag(cur, FLAG_RESPONSE) != resp) + continue; + if (ast_test_flag(cur, FLAG_RESPONSE) || cur->method == sipmethod) { + msg = "Found"; if (!resp && (seqno == p->pendinginvite)) { if (option_debug) ast_log(LOG_DEBUG, "Acked pending invite %d\n", p->pendinginvite); p->pendinginvite = 0; } - /* this is our baby */ - res = TRUE; - UNLINK(cur, p->packets, prev); if (cur->retransid > -1) { if (sipdebug && option_debug > 3) ast_log(LOG_DEBUG, "** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid); ast_sched_del(sched, cur->retransid); } + UNLINK(cur, p->packets, prev); free(cur); break; } } sip_pvt_unlock(p); if (option_debug) - ast_log(LOG_DEBUG, "Stopping retransmission on '%s' of %s %d: Match %s\n", p->callid, resp ? "Response" : "Request", seqno, res ? "Not Found" : "Found"); + ast_log(LOG_DEBUG, "Stopping retransmission on '%s' of %s %d: Match %s\n", + p->callid, resp ? "Response" : "Request", seqno, msg); } /*! \brief Pretend to ack all packets -- GitLab