diff options
author | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-11-13 14:29:31 +0000 |
---|---|---|
committer | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-11-13 14:29:31 +0000 |
commit | b01f2aed4f11e069e930fd9c858a13eecc5db4f5 (patch) | |
tree | 3dbb2ba097caace2d53c28ea429335f9aecbc4e4 /channels/chan_sip.c | |
parent | e015f388000bfb5216ea053178addb9a7396dc11 (diff) |
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: http://svn.digium.com/svn/asterisk/trunk@47539 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r-- | channels/chan_sip.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 243d139f4..cc97297a8 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; } |