[asterisk-commits] mmichelson: branch mmichelson/pubsub_bodies r405860 - /team/mmichelson/pubsub...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jan 17 14:44:05 CST 2014


Author: mmichelson
Date: Fri Jan 17 14:43:57 2014
New Revision: 405860

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=405860
Log:
Add locking to the body_generators list.


Modified:
    team/mmichelson/pubsub_bodies/res/res_pjsip_pubsub.c

Modified: team/mmichelson/pubsub_bodies/res/res_pjsip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/pubsub_bodies/res/res_pjsip_pubsub.c?view=diff&rev=405860&r1=405859&r2=405860
==============================================================================
--- team/mmichelson/pubsub_bodies/res/res_pjsip_pubsub.c (original)
+++ team/mmichelson/pubsub_bodies/res/res_pjsip_pubsub.c Fri Jan 17 14:43:57 2014
@@ -1064,11 +1064,12 @@
 	return pjsip_tsx_send_msg(tsx, tdata);
 }
 
-AST_LIST_HEAD_STATIC(body_generators, ast_sip_pubsub_body_generator);
+AST_RWLIST_HEAD_STATIC(body_generators, ast_sip_pubsub_body_generator);
 
 int ast_sip_pubsub_register_body_generator(struct ast_sip_pubsub_body_generator *generator)
 {
 	struct ast_sip_pubsub_body_generator *iter;
+	SCOPED_LOCK(lock, &body_generators, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
 
 	if (generator->generator_type == AST_SIP_PUBSUB_BODY_GENERATOR_SUPPLEMENTARY) {
 		AST_LIST_INSERT_TAIL(&body_generators, generator, list);
@@ -1097,6 +1098,7 @@
 void ast_sip_pubsub_unregister_body_generator(struct ast_sip_pubsub_body_generator *generator)
 {
 	struct ast_sip_pubsub_body_generator *iter;
+	SCOPED_LOCK(lock, &body_generators, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
 
 	AST_LIST_TRAVERSE_SAFE_BEGIN(&body_generators, iter, list) {
 		if (iter == generator) {
@@ -1112,6 +1114,7 @@
 {
 	struct ast_sip_pubsub_body_generator *iter;
 	int res = -1;
+	SCOPED_LOCK(lock, &body_generators, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK);
 
 	AST_LIST_TRAVERSE(&body_generators, iter, list) {
 		if (!strcmp(content_type, iter->type) &&




More information about the asterisk-commits mailing list