From: Luigi Rizzo Date: Mon, 13 Nov 2006 14:29:31 +0000 (+0000) Subject: merge from astobj2-r47450: use UNLINK to remove a packet from its queue, X-Git-Tag: 1.6.0-beta1~3^2~4016 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52148c96f56f856be7cb03fc3eb9dd85a6af4c01;p=thirdparty%2Fasterisk.git merge from astobj2-r47450: use UNLINK to remove a packet from its queue, and related code rearrangement. Approved by: oej This could be made better if we declared struct sip_pvt *dialpg = pkt->owner; at the beginning of the function, and use it throughout the function. I'll let the boss decide :) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@47539 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 243d139f46..cc97297a8b 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -1930,23 +1930,18 @@ static int retrans_pkt(void *data) ast_set_flag(&pkt->owner->flags[0], SIP_NEEDDESTROY); } } - /* In any case, go ahead and remove the packet */ + /* Remove the packet */ for (prev = NULL, cur = pkt->owner->packets; cur; prev = cur, cur = cur->next) { - if (cur == pkt) - break; + if (cur == pkt) { + UNLINK(cur, pkt->owner->packets, prev); + sip_pvt_unlock(pkt->owner); + free(pkt); + return 0; + } } - if (cur) { - if (prev) - prev->next = cur->next; - else - pkt->owner->packets = cur->next; - sip_pvt_unlock(pkt->owner); - free(cur); - pkt = NULL; - } else - ast_log(LOG_WARNING, "Weird, couldn't find packet owner!\n"); - if (pkt) - sip_pvt_unlock(pkt->owner); + /* error case */ + ast_log(LOG_WARNING, "Weird, couldn't find packet owner!\n"); + sip_pvt_unlock(pkt->owner); return 0; }