[asterisk-commits] rizzo: branch rizzo/astobj2 r47265 -
/team/rizzo/astobj2/channels/chan_sip.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Nov 7 09:10:49 MST 2006
Author: rizzo
Date: Tue Nov 7 10:10:49 2006
New Revision: 47265
URL: http://svn.digium.com/view/asterisk?rev=47265&view=rev
Log:
move the body of get_sip_pvt_byid_locked() to a separate function.
There is a bug in the existing code here, reported in mantis,
bug #8303
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?rev=47265&r1=47264&r2=47265&view=diff
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Tue Nov 7 10:10:49 2006
@@ -8596,6 +8596,38 @@
return -1;
}
+struct __find_byid_arg {
+ const char *callid;
+ const char *fromtag;
+ const char *totag;
+};
+
+static int find_pvt_byid_cb(struct sip_pvt *pvt, struct __find_byid_arg *arg)
+{
+ if (strcmp(pvt->callid, arg->callid))
+ return 0; /* not found */
+
+ /* Go ahead and lock it (and its owner) before returning */
+ sip_pvt_lock(pvt);
+
+ /* Check if tags match. If not, this is not the call we want
+ (With a forking SIP proxy, several call legs share the
+ call id, but have different tags)
+ */
+ if (pedanticsipchecking && (strcmp(arg->fromtag, pvt->theirtag) || strcmp(arg->totag, pvt->tag))) {
+ sip_pvt_unlock(pvt);
+ return 0;
+ }
+
+ if (option_debug > 3 && arg->totag)
+ ast_log(LOG_DEBUG, "Matched %s call - their tag is %s Our tag is %s\n",
+ ast_test_flag(&pvt->flags[0], SIP_OUTGOING) ? "OUTGOING": "INCOMING",
+ pvt->theirtag, pvt->tag);
+
+ lock_pvt_and_owner(pvt, 0 /* try forever */); /* safe, dialoglist is locked */
+ return 1;
+}
+
/*! \brief Lock dialog lock and find matching pvt lock
- Their tag is fromtag, our tag is to-tag
- This means that in some transactions, totag needs to be their tag :-)
@@ -8604,6 +8636,11 @@
static struct sip_pvt *get_sip_pvt_byid_locked(const char *callid, const char *totag, const char *fromtag)
{
struct sip_pvt *sip_pvt_ptr;
+ struct __find_byid_arg arg;
+
+ arg.callid = callid;
+ arg.fromtag = fromtag;
+ arg.totag = totag;
dialoglist_lock();
@@ -8612,33 +8649,8 @@
/* Search dialogs and find the match */
for (sip_pvt_ptr = dialoglist; sip_pvt_ptr; sip_pvt_ptr = sip_pvt_ptr->next) {
- if (!strcmp(sip_pvt_ptr->callid, callid)) {
- int match = 1;
- char *ourtag = sip_pvt_ptr->tag;
-
- /* Go ahead and lock it (and its owner) before returning */
- sip_pvt_lock(sip_pvt_ptr);
-
- /* Check if tags match. If not, this is not the call we want
- (With a forking SIP proxy, several call legs share the
- call id, but have different tags)
- */
- if (pedanticsipchecking && (strcmp(fromtag, sip_pvt_ptr->theirtag) || strcmp(totag, ourtag)))
- match = 0;
-
- if (!match) {
- sip_pvt_unlock(sip_pvt_ptr);
- break;
- }
-
- if (option_debug > 3 && totag)
- ast_log(LOG_DEBUG, "Matched %s call - their tag is %s Our tag is %s\n",
- ast_test_flag(&sip_pvt_ptr->flags[0], SIP_OUTGOING) ? "OUTGOING": "INCOMING",
- sip_pvt_ptr->theirtag, sip_pvt_ptr->tag);
-
- lock_pvt_and_owner(sip_pvt_ptr, 0 /* try forever */); /* safe, dialoglist is locked */
+ if (find_pvt_byid_cb(sip_pvt_ptr, &arg))
break;
- }
}
dialoglist_unlock();
if (option_debug > 3 && !sip_pvt_ptr)
More information about the asterisk-commits
mailing list