[svn-commits] murf: branch murf/bug11210 r99076 - /team/murf/bug11210/channels/chan_iax2.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jan 18 13:16:50 CST 2008


Author: murf
Date: Fri Jan 18 13:16:49 2008
New Revision: 99076

URL: http://svn.digium.com/view/asterisk?view=rev&rev=99076
Log:
Another checkpoint; rebuild the find_callno routine to use the hash tables; still need to verify I have all the spots where the values are twiddled. Maybe I should store the callno's instead of the pvt pointers in the hashes, as I have to back-convert them.

Modified:
    team/murf/bug11210/channels/chan_iax2.c

Modified: team/murf/bug11210/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/chan_iax2.c?view=diff&rev=99076&r1=99075&r2=99076
==============================================================================
--- team/murf/bug11210/channels/chan_iax2.c (original)
+++ team/murf/bug11210/channels/chan_iax2.c Fri Jan 18 13:16:49 2008
@@ -1557,6 +1557,8 @@
 #define NEW_ALLOW 	1
 #define NEW_FORCE 	2
 
+#ifdef OLD_CODE
+
 static int match(struct sockaddr_in *sin, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur)
 {
 	if ((cur->addr.sin_addr.s_addr == sin->sin_addr.s_addr) &&
@@ -1576,6 +1578,8 @@
 	}
 	return 0;
 }
+
+#endif
 
 static void update_max_trunk(void)
 {
@@ -1665,13 +1669,22 @@
  *
  * \note Calling this function while holding another pvt lock can cause a deadlock.
  */
+
+static struct chan_iax2_pvt *tmp_pvt_ptr = NULL;
+
 static int find_callno(unsigned short callno, unsigned short dcallno, struct sockaddr_in *sin, int new, int sockfd)
 {
 	int res = 0;
 	int x;
 	struct timeval now;
 	char host[80];
-
+	struct chan_iax2_pvt *respvt;
+
+	if (tmp_pvt_ptr == NULL) {
+		tmp_pvt_ptr = new_iax(NULL, "huh"); /* do this ONCE, and we can use it ever after that for hash lookups */
+	}
+	
+#ifdef OLD_CODE
 	if (new <= NEW_ALLOW) {
 		for (x=1;(res < 1) && (x<maxnontrunkcall);x++) {
 			ast_mutex_lock(&iaxsl[x]);
@@ -1694,6 +1707,34 @@
 			ast_mutex_unlock(&iaxsl[x]);
 		}
 	}
+#endif
+	tmp_pvt_ptr->addr = *sin;
+	tmp_pvt_ptr->peercallno = callno;
+	respvt = ao2_t_find(findcall1, tmp_pvt_ptr, OBJ_POINTER, "Find the pvt in the findcall1 table");
+	/* keep looking ! */
+	if (respvt)
+		res = respvt->callno;
+	if (!res && callno == 0) {
+		tmp_pvt_ptr->callno = dcallno;
+		respvt = ao2_t_find(findcall2, tmp_pvt_ptr, OBJ_POINTER, "Find the pvt in the findcall1 table");
+		if (respvt)
+			res = respvt->callno;
+	}
+	if (!res) {
+		tmp_pvt_ptr->callno = dcallno; /* just in case */
+		tmp_pvt_ptr->transfer = *sin;
+		respvt = ao2_t_find(findcall3, tmp_pvt_ptr, OBJ_POINTER, "Find the pvt in the findcall1 table");
+		if (respvt)
+			res = respvt->callno;
+	}
+	if (!res) {
+		tmp_pvt_ptr->transfercallno = dcallno;
+		/* transfer should still be in place from the previous test setup */
+		respvt = ao2_t_find(findcall4, tmp_pvt_ptr, OBJ_POINTER, "Find the pvt in the findcall1 table");
+		if (respvt)
+			res = respvt->callno;
+	}
+	
 	if ((res < 1) && (new >= NEW_ALLOW)) {
 		/* It may seem odd that we look through the peer list for a name for
 		 * this *incoming* call.  Well, it is weird.  However, users don't
@@ -9158,6 +9199,7 @@
 					/* Start sending our media to the transfer address, but otherwise leave the call as-is */
 					iaxs[fr->callno]->transferring = TRANSFER_MEDIAPASS;
 					ao2_t_link(findcall4, iaxs[fr->callno], "This pvt is being set in MEDIAPASS state, adding to findcall4");
+					/* should already be in findcall3 */
 				}
 				break;	
 			case IAX_COMMAND_DPREP:




More information about the svn-commits mailing list