[asterisk-commits] rmudgett: branch 13 r430687 - in /branches/13/res: res_fax.c res_fax_spandsp.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 15 11:35:13 CST 2015


Author: rmudgett
Date: Thu Jan 15 11:35:05 2015
New Revision: 430687

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=430687
Log:
res_fax.c, res_fax_spandsp.c: Remove redundant locking.

When FAX was developed, apparently the faxregistry.container used to be a
linked list that was converted to an ao2 container.  Some of the
replacement ao2 container operations still had explicit lock/unlocks
around them.

Three off nominal code paths in res_fax.c and res_fax_spandsp.c unlock the
channel even though the routine did not lock the channel and other code
paths in the routine do not unlock the channel.

Review: https://reviewboard.asterisk.org/r/4340/

Modified:
    branches/13/res/res_fax.c
    branches/13/res/res_fax_spandsp.c

Modified: branches/13/res/res_fax.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/res/res_fax.c?view=diff&rev=430687&r1=430686&r2=430687
==============================================================================
--- branches/13/res/res_fax.c (original)
+++ branches/13/res/res_fax.c Thu Jan 15 11:35:05 2015
@@ -1626,21 +1626,15 @@
 		orig_write_format = ao2_bump(ast_channel_writeformat(chan));
 		if (ast_set_write_format(chan, ast_format_slin) < 0) {
 			ast_log(LOG_ERROR, "channel '%s' failed to set write format to signed linear'.\n", ast_channel_name(chan));
- 			ao2_lock(faxregistry.container);
- 			ao2_unlink(faxregistry.container, fax);
- 			ao2_unlock(faxregistry.container);
- 			ao2_ref(fax, -1);
-			ast_channel_unlock(chan);
+			ao2_unlink(faxregistry.container, fax);
+			ao2_ref(fax, -1);
 			return -1;
 		}
 		orig_read_format = ao2_bump(ast_channel_readformat(chan));
 		if (ast_set_read_format(chan, ast_format_slin) < 0) {
 			ast_log(LOG_ERROR, "channel '%s' failed to set read format to signed linear.\n", ast_channel_name(chan));
- 			ao2_lock(faxregistry.container);
- 			ao2_unlink(faxregistry.container, fax);
- 			ao2_unlock(faxregistry.container);
- 			ao2_ref(fax, -1);
-			ast_channel_unlock(chan);
+			ao2_unlink(faxregistry.container, fax);
+			ao2_ref(fax, -1);
 			return -1;
 		}
 		if (fax->smoother) {
@@ -1818,9 +1812,7 @@
 	}
 
 	if (fax) {
-		ao2_lock(faxregistry.container);
 		ao2_unlink(faxregistry.container, fax);
-		ao2_unlock(faxregistry.container);
 		ao2_ref(fax, -1);
 	}
 
@@ -2806,18 +2798,14 @@
 static void destroy_v21_sessions(struct fax_gateway *gateway)
 {
 	if (gateway->chan_v21_session) {
-		ao2_lock(faxregistry.container);
 		ao2_unlink(faxregistry.container, gateway->chan_v21_session);
-		ao2_unlock(faxregistry.container);
 
 		ao2_ref(gateway->chan_v21_session, -1);
 		gateway->chan_v21_session = NULL;
 	}
 
 	if (gateway->peer_v21_session) {
-		ao2_lock(faxregistry.container);
 		ao2_unlink(faxregistry.container, gateway->peer_v21_session);
-		ao2_unlock(faxregistry.container);
 
 		ao2_ref(gateway->peer_v21_session, -1);
 		gateway->peer_v21_session = NULL;
@@ -2835,9 +2823,7 @@
 		fax_session_release(gateway->s, gateway->token);
 		gateway->token = NULL;
 
-		ao2_lock(faxregistry.container);
 		ao2_unlink(faxregistry.container, gateway->s);
-		ao2_unlock(faxregistry.container);
 
 		ao2_ref(gateway->s, -1);
 		gateway->s = NULL;

Modified: branches/13/res/res_fax_spandsp.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/res/res_fax_spandsp.c?view=diff&rev=430687&r1=430686&r2=430687
==============================================================================
--- branches/13/res/res_fax_spandsp.c (original)
+++ branches/13/res/res_fax_spandsp.c Thu Jan 15 11:35:05 2015
@@ -836,8 +836,8 @@
 
 	p->ist38 = 1;
 	p->ast_t38_state = ast_channel_get_t38_state(s->chan);
-	if (!(peer = ast_channel_bridge_peer(s->chan))) {
-		ast_channel_unlock(s->chan);
+	peer = ast_channel_bridge_peer(s->chan);
+	if (!peer) {
 		return -1;
 	}
 




More information about the asterisk-commits mailing list