[svn-commits] file: trunk r49089 - /trunk/channels/chan_iax2.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Sun Dec 31 12:15:24 MST 2006


Author: file
Date: Sun Dec 31 13:15:23 2006
New Revision: 49089

URL: http://svn.digium.com/view/asterisk?view=rev&rev=49089
Log:
count is no longer used in the iaxq structure really so let's just make this a statically declared linked list.

Modified:
    trunk/channels/chan_iax2.c

Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=49089&r1=49088&r2=49089
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Sun Dec 31 13:15:23 2006
@@ -629,10 +629,7 @@
 	int frames_received;
 };
 
-static struct ast_iax2_queue {
-	AST_LIST_HEAD(, iax_frame) queue;
-	int count;
-} iaxq;
+static AST_LIST_HEAD_STATIC(queue, iax_frame);
 
 static AST_LIST_HEAD_STATIC(users, iax2_user);
 
@@ -1808,13 +1805,13 @@
 			ast_queue_hangup(owner);
 		}
 
-		AST_LIST_LOCK(&iaxq.queue);
-		AST_LIST_TRAVERSE(&iaxq.queue, cur, list) {
+		AST_LIST_LOCK(&queue);
+		AST_LIST_TRAVERSE(&queue, cur, list) {
 			/* Cancel any pending transmissions */
 			if (cur->callno == pvt->callno) 
 				cur->retries = -1;
 		}
-		AST_LIST_UNLOCK(&iaxq.queue);
+		AST_LIST_UNLOCK(&queue);
 
 		if (pvt->reg)
 			pvt->reg->callno = 0;
@@ -1924,10 +1921,9 @@
 	/* Do not try again */
 	if (freeme) {
 		/* Don't attempt delivery, just remove it from the queue */
-		AST_LIST_LOCK(&iaxq.queue);
-		AST_LIST_REMOVE(&iaxq.queue, f, list);
-		iaxq.count--;
-		AST_LIST_UNLOCK(&iaxq.queue);
+		AST_LIST_LOCK(&queue);
+		AST_LIST_REMOVE(&queue, f, list);
+		AST_LIST_UNLOCK(&queue);
 		f->retrans = -1;
 		/* Free the IAX frame */
 		iax2_frame_free(f);
@@ -2126,15 +2122,15 @@
 	if (argc != 3)
 		return RESULT_SHOWUSAGE;
 
-	AST_LIST_LOCK(&iaxq.queue);
-	AST_LIST_TRAVERSE(&iaxq.queue, cur, list) {
+	AST_LIST_LOCK(&queue);
+	AST_LIST_TRAVERSE(&queue, cur, list) {
 		if (cur->retries < 0)
 			dead++;
 		if (cur->final)
 			final++;
 		cnt++;
 	}
-	AST_LIST_UNLOCK(&iaxq.queue);
+	AST_LIST_UNLOCK(&queue);
 
 	ast_cli(fd, "    IAX Statistics\n");
 	ast_cli(fd, "---------------------\n");
@@ -2457,10 +2453,9 @@
 	/* By setting this to 0, the network thread will send it for us, and
 	   queue retransmission if necessary */
 	fr->sentyet = 0;
-	AST_LIST_LOCK(&iaxq.queue);
-	AST_LIST_INSERT_TAIL(&iaxq.queue, fr, list);
-	iaxq.count++;
-	AST_LIST_UNLOCK(&iaxq.queue);
+	AST_LIST_LOCK(&queue);
+	AST_LIST_INSERT_TAIL(&queue, fr, list);
+	AST_LIST_UNLOCK(&queue);
 	/* Wake up the network and scheduler thread */
 	pthread_kill(netthreadid, SIGURG);
 	signal_condition(&sched_lock, &sched_cond);
@@ -5403,15 +5398,15 @@
 	pvt->lastsent = 0;
 	pvt->nextpred = 0;
 	pvt->pingtime = DEFAULT_RETRY_TIME;
-	AST_LIST_LOCK(&iaxq.queue);
-	AST_LIST_TRAVERSE(&iaxq.queue, cur, list) {
+	AST_LIST_LOCK(&queue);
+	AST_LIST_TRAVERSE(&queue, cur, list) {
 		/* We must cancel any packets that would have been transmitted
 		   because now we're talking to someone new.  It's okay, they
 		   were transmitted to someone that didn't care anyway. */
 		if (callno == cur->callno) 
 			cur->retries = -1;
 	}
-	AST_LIST_UNLOCK(&iaxq.queue);
+	AST_LIST_UNLOCK(&queue);
 	return 0; 
 }
 
@@ -5926,15 +5921,15 @@
 {
 	struct iax_frame *f;
 
-	AST_LIST_LOCK(&iaxq.queue);
-	AST_LIST_TRAVERSE(&iaxq.queue, f, list) {
+	AST_LIST_LOCK(&queue);
+	AST_LIST_TRAVERSE(&queue, f, list) {
 		/* Send a copy immediately */
 		if ((f->callno == callno) && iaxs[f->callno] &&
 			(f->oseqno >= last)) {
 			send_packet(f);
 		}
 	}
-	AST_LIST_UNLOCK(&iaxq.queue);
+	AST_LIST_UNLOCK(&queue);
 }
 
 static void __iax2_poke_peer_s(void *data)
@@ -6657,8 +6652,8 @@
 					/* Ack the packet with the given timestamp */
 					if (option_debug && iaxdebug)
 						ast_log(LOG_DEBUG, "Cancelling transmission of packet %d\n", x);
-					AST_LIST_LOCK(&iaxq.queue);
-					AST_LIST_TRAVERSE(&iaxq.queue, cur, list) {
+					AST_LIST_LOCK(&queue);
+					AST_LIST_TRAVERSE(&queue, cur, list) {
 						/* If it's our call, and our timestamp, mark -1 retries */
 						if ((fr->callno == cur->callno) && (x == cur->oseqno)) {
 							cur->retries = -1;
@@ -6670,7 +6665,7 @@
 							}
 						}
 					}
-					AST_LIST_UNLOCK(&iaxq.queue);
+					AST_LIST_UNLOCK(&queue);
 				}
 				/* Note how much we've received acknowledgement for */
 				if (iaxs[fr->callno])
@@ -6815,13 +6810,13 @@
 			case IAX_COMMAND_TXACC:
 				if (iaxs[fr->callno]->transferring == TRANSFER_BEGIN) {
 					/* Ack the packet with the given timestamp */
-					AST_LIST_LOCK(&iaxq.queue);
-					AST_LIST_TRAVERSE(&iaxq.queue, cur, list) {
+					AST_LIST_LOCK(&queue);
+					AST_LIST_TRAVERSE(&queue, cur, list) {
 						/* Cancel any outstanding txcnt's */
 						if ((fr->callno == cur->callno) && (cur->transfer))
 							cur->retries = -1;
 					}
-					AST_LIST_UNLOCK(&iaxq.queue);
+					AST_LIST_UNLOCK(&queue);
 					memset(&ied1, 0, sizeof(ied1));
 					iax_ie_append_short(&ied1, IAX_IE_CALLNO, iaxs[fr->callno]->callno);
 					send_command(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_TXREADY, 0, ied1.buf, ied1.pos, -1);
@@ -8135,10 +8130,10 @@
 	for(;;) {
 		/* Go through the queue, sending messages which have not yet been
 		   sent, and scheduling retransmissions if appropriate */
-		AST_LIST_LOCK(&iaxq.queue);
+		AST_LIST_LOCK(&queue);
 		count = 0;
 		wakeup = -1;
-		AST_LIST_TRAVERSE_SAFE_BEGIN(&iaxq.queue, f, list) {
+		AST_LIST_TRAVERSE_SAFE_BEGIN(&queue, f, list) {
 			if (f->sentyet)
 				continue;
 			
@@ -8159,8 +8154,7 @@
 
 			if (f->retries < 0) {
 				/* This is not supposed to be retransmitted */
-				AST_LIST_REMOVE(&iaxq.queue, f, list);
-				iaxq.count--;
+				AST_LIST_REMOVE(&queue, f, list);
 				/* Free the iax frame */
 				iax_frame_free(f);
 			} else {
@@ -8171,7 +8165,7 @@
 			}
 		}
 		AST_LIST_TRAVERSE_SAFE_END
-		AST_LIST_UNLOCK(&iaxq.queue);
+		AST_LIST_UNLOCK(&queue);
 
 		if (count >= 20 && option_debug)
 			ast_log(LOG_DEBUG, "chan_iax2: Sent %d queued outbound frames all at once\n", count);
@@ -9984,8 +9978,6 @@
 	AST_LIST_TRAVERSE_SAFE_END
 	AST_LIST_UNLOCK(&dynamic_list);
 
-	AST_LIST_HEAD_DESTROY(&iaxq.queue);
-
 	ast_netsock_release(netsock);
 	for (x=0;x<IAX_MAX_CALLS;x++)
 		if (iaxs[x])
@@ -10059,8 +10051,6 @@
 	}
 
 	ast_netsock_init(netsock);
-
-	AST_LIST_HEAD_INIT(&iaxq.queue);
 	
 	ast_cli_register_multiple(cli_iax2, sizeof(cli_iax2) / sizeof(struct ast_cli_entry));
 



More information about the svn-commits mailing list