[asterisk-commits] rizzo: branch rizzo/astobj2 r47451 -
/team/rizzo/astobj2/channels/chan_sip.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri Nov 10 11:41:27 MST 2006
Author: rizzo
Date: Fri Nov 10 12:41:27 2006
New Revision: 47451
URL: http://svn.digium.com/view/asterisk?view=rev&rev=47451
Log:
simplify __sip_ack(), avoid recomputing a strlen() twice for each
packet in the retransmit queue, instead do it once at the beginning
of the loop.
definitely a trunk candidate, for performance reasons.
Modified:
team/rizzo/astobj2/channels/chan_sip.c
Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=47451&r1=47450&r2=47451
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Fri Nov 10 12:41:27 2006
@@ -2148,31 +2148,29 @@
struct sip_pkt *cur, *prev = NULL;
/* Just in case... */
- char *msg;
int res = FALSE;
-
- msg = sip_methods[sipmethod].text;
+ char *msg = sip_methods[sipmethod].text;
+ int len = strlen(msg);
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;
+ /* XXX need to tokenize packets, rather than doing a stcasecmp */
+ if ((ast_test_flag(cur, FLAG_RESPONSE) || (!strncasecmp(msg, cur->data, len) && cur->data[len] < 33))) {
+ res = TRUE; /* this is our packet */
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);
}
- if (cur->pvt) /* XXX should be always */
- cur->pvt = pvt_unref(cur->pvt);
+ UNLINK(cur, p->packets, prev);
+ cur->pvt = pvt_unref(cur->pvt);
free(cur);
break;
}
More information about the asterisk-commits
mailing list