[asterisk-commits] rizzo: trunk r47539 - /trunk/channels/chan_sip.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon Nov 13 07:29:31 MST 2006
Author: rizzo
Date: Mon Nov 13 08:29:31 2006
New Revision: 47539
URL: http://svn.digium.com/view/asterisk?view=rev&rev=47539
Log:
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 :)
Modified:
trunk/channels/chan_sip.c
Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=47539&r1=47538&r2=47539
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Mon Nov 13 08:29:31 2006
@@ -1930,23 +1930,18 @@
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) {
- 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);
+ if (cur == pkt) {
+ UNLINK(cur, pkt->owner->packets, prev);
+ sip_pvt_unlock(pkt->owner);
+ free(pkt);
+ return 0;
+ }
+ }
+ /* error case */
+ ast_log(LOG_WARNING, "Weird, couldn't find packet owner!\n");
+ sip_pvt_unlock(pkt->owner);
return 0;
}
More information about the asterisk-commits
mailing list