[asterisk-commits] file: trunk r51467 - /trunk/main/rtp.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Jan 22 16:53:17 MST 2007


Author: file
Date: Mon Jan 22 17:53:16 2007
New Revision: 51467

URL: http://svn.digium.com/view/asterisk?view=rev&rev=51467
Log:
Change RTP protos list to be read/write. Most of the time it's only going to be read so making it use mutex locks was a waste.

Modified:
    trunk/main/rtp.c

Modified: trunk/main/rtp.c
URL: http://svn.digium.com/view/asterisk/trunk/main/rtp.c?view=diff&rev=51467&r1=51466&r2=51467
==============================================================================
--- trunk/main/rtp.c (original)
+++ trunk/main/rtp.c Mon Jan 22 17:53:16 2007
@@ -497,7 +497,7 @@
 }
 
 /*! \brief List of current sessions */
-static AST_LIST_HEAD_STATIC(protos, ast_rtp_protocol);
+static AST_RWLIST_HEAD_STATIC(protos, ast_rtp_protocol);
 
 static void timeval2ntp(struct timeval tv, unsigned int *msw, unsigned int *lsw)
 {
@@ -1491,12 +1491,12 @@
 {
 	struct ast_rtp_protocol *cur = NULL;
 
-	AST_LIST_LOCK(&protos);
-	AST_LIST_TRAVERSE(&protos, cur, list) {
+	AST_RWLIST_RDLOCK(&protos);
+	AST_RWLIST_TRAVERSE(&protos, cur, list) {
 		if (cur->type == chan->tech->type)
 			break;
 	}
-	AST_LIST_UNLOCK(&protos);
+	AST_RWLIST_UNLOCK(&protos);
 
 	return cur;
 }
@@ -2780,9 +2780,9 @@
 /*! \brief Unregister interface to channel driver */
 void ast_rtp_proto_unregister(struct ast_rtp_protocol *proto)
 {
-	AST_LIST_LOCK(&protos);
-	AST_LIST_REMOVE(&protos, proto, list);
-	AST_LIST_UNLOCK(&protos);
+	AST_RWLIST_WRLOCK(&protos);
+	AST_RWLIST_REMOVE(&protos, proto, list);
+	AST_RWLIST_UNLOCK(&protos);
 }
 
 /*! \brief Register interface to channel driver */
@@ -2790,16 +2790,16 @@
 {
 	struct ast_rtp_protocol *cur;
 
-	AST_LIST_LOCK(&protos);
-	AST_LIST_TRAVERSE(&protos, cur, list) {	
+	AST_RWLIST_WRLOCK(&protos);
+	AST_RWLIST_TRAVERSE(&protos, cur, list) {	
 		if (!strcmp(cur->type, proto->type)) {
 			ast_log(LOG_WARNING, "Tried to register same protocol '%s' twice\n", cur->type);
-			AST_LIST_UNLOCK(&protos);
+			AST_RWLIST_UNLOCK(&protos);
 			return -1;
 		}
 	}
-	AST_LIST_INSERT_HEAD(&protos, proto, list);
-	AST_LIST_UNLOCK(&protos);
+	AST_RWLIST_INSERT_HEAD(&protos, proto, list);
+	AST_RWLIST_UNLOCK(&protos);
 	
 	return 0;
 }



More information about the asterisk-commits mailing list