[asterisk-commits] mmichelson: branch mmichelson/res_sip r378709 - /team/mmichelson/res_sip/res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 9 09:27:07 CST 2013


Author: mmichelson
Date: Wed Jan  9 09:27:03 2013
New Revision: 378709

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=378709
Log:
Switch endpoint identifier to be an RWLIST.

This will reduce contention during the many times endpoints
are looked up.


Modified:
    team/mmichelson/res_sip/res/res_sip.c

Modified: team/mmichelson/res_sip/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/res_sip/res/res_sip.c?view=diff&rev=378709&r1=378708&r2=378709
==============================================================================
--- team/mmichelson/res_sip/res/res_sip.c (original)
+++ team/mmichelson/res_sip/res/res_sip.c Wed Jan  9 09:27:03 2013
@@ -107,38 +107,38 @@
 
 struct endpoint_identifier_list {
 	struct ast_sip_endpoint_identifier *identifier;
-	AST_LIST_ENTRY(endpoint_identifier_list) list;
+	AST_RWLIST_ENTRY(endpoint_identifier_list) list;
 }
 
-AST_LIST_HEAD(, endpoint_identifier_list) endpoint_identifiers;
+AST_RWLIST_HEAD_STATIC(endpoint_identifiers, endpoint_identifier_list);
 
 int ast_sip_register_endpoint_identifier(struct ast_sip_endpoint_identifier *identifier)
 {
-	SCOPED_LOCK(lock, &endpoint_identifiers, AST_LIST_LOCK, AST_LIST_UNLOCK);
-	AST_LIST_INSERT_TAIL(&endpoint_identifiers);
+	SCOPED_LOCK(lock, &endpoint_identifiers, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
+	AST_RWLIST_INSERT_TAIL(&endpoint_identifiers);
 	ast_debug(1, "Registered endpoint identifier %p\n", identifier);
 }
 
 void ast_sip_unregister_endpoint_identifier(struct ast_sip_endpoint_identifier *identifier)
 {
 	struct endpoint_identifier_list *iter;
-	SCOPED_LOCK(lock, &endpoint_identifiers, AST_LIST_LOCK, AST_LIST_UNLOCK);
-	AST_LIST_TRAVERSE_SAFE_BEGIN(&endpoint_identifiers, iter, list) {
+	SCOPED_LOCK(lock, &endpoint_identifiers, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
+	AST_RWLIST_TRAVERSE_SAFE_BEGIN(&endpoint_identifiers, iter, list) {
 		if (iter->identifier == identifier) {
-			AST_LIST_REMOVE_CURRENT(list);
+			AST_RWLIST_REMOVE_CURRENT(list);
 			ast_debug(1, "Unregistered endpoint identifier %p\n", identifier);
 			break;
 		}
 	}
-	AST_LIST_TRAVERSE_SAFE_END;
+	AST_RWLIST_TRAVERSE_SAFE_END;
 }
 
 struct ast_sip_endpoint *ast_sip_identify_endpoint(struct pjsip_rx_data *rdata)
 {
 	struct endpoint_identifier_list *iter;
 	struct ast_sip_endpoint *endpoint;
-	SCOPED_LOCK(lock, &endpoint_identifiers, AST_LIST_LOCK, AST_LIST_UNLOCK);
-	AST_LIST_TRAVERSE(&endpoint_identifiers, iter, list) {
+	SCOPED_LOCK(lock, &endpoint_identifiers, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK);
+	AST_RWLIST_TRAVERSE(&endpoint_identifiers, iter, list) {
 		ast_assert(iter->identifier->identify_endpoint != NULL);
 		endpoint = iter->identifier->identify_endpoint(rdata);
 		if (endpoint) {




More information about the asterisk-commits mailing list