[asterisk-commits] pcadach: branch 1.4 r44166 - /branches/1.4/channels/chan_h323.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Oct 2 10:15:11 MST 2006


Author: pcadach
Date: Mon Oct  2 12:15:11 2006
New Revision: 44166

URL: http://svn.digium.com/view/asterisk?rev=44166&view=rev
Log:
Optimization of oh323_indicate(): less locks - less problems, plus single exit point

Modified:
    branches/1.4/channels/chan_h323.c

Modified: branches/1.4/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_h323.c?rev=44166&r1=44165&r2=44166&view=diff
==============================================================================
--- branches/1.4/channels/chan_h323.c (original)
+++ branches/1.4/channels/chan_h323.c Mon Oct  2 12:15:11 2006
@@ -870,6 +870,8 @@
 	got_progress = pvt->got_progress;
 	if (condition == AST_CONTROL_PROGRESS)
 		pvt->got_progress = 1;
+	else if ((condition == AST_CONTROL_BUSY) || (condition == AST_CONTROL_CONGESTION))
+		pvt->alreadygone = 1;
 	ast_mutex_unlock(&pvt->lock);
 
 	if (h323debug)
@@ -880,69 +882,48 @@
 		if (c->_state == AST_STATE_RING || c->_state == AST_STATE_RINGING) {
 			h323_send_alerting(token);
 			res = (got_progress ? 0 : -1);	/* Do not simulate any audio tones if we got PROGRESS message */
-			break;
-		}
-		if (token)
-			free(token);
-		return -1;
+		}
+		break;
 	case AST_CONTROL_PROGRESS:
 		if (c->_state != AST_STATE_UP) {
 			/* Do not send PROGRESS message more than once */
 			if (!got_progress)
 				h323_send_progress(token);
-			break;
-		}
-		if (token)
-			free(token);
-		return -1;
+			res = 0;
+		}
+		break;
 	case AST_CONTROL_BUSY:
 		if (c->_state != AST_STATE_UP) {
 			h323_answering_call(token, 1);
-			ast_mutex_lock(&pvt->lock);
-			pvt->alreadygone = 1;
-			ast_mutex_unlock(&pvt->lock);
 			ast_softhangup_nolock(c, AST_SOFTHANGUP_DEV);
-			break;
-		}
-		if (token)
-			free(token);
-		return -1;
+			res = 0;
+		}
+		break;
 	case AST_CONTROL_CONGESTION:
 		if (c->_state != AST_STATE_UP) {
 			h323_answering_call(token, 1);
-			ast_mutex_lock(&pvt->lock);
-			pvt->alreadygone = 1;
-			ast_mutex_unlock(&pvt->lock);
 			ast_softhangup_nolock(c, AST_SOFTHANGUP_DEV);
-			break;
-		}
-		if (token)
-			free(token);
-		return -1;
+			res = 0;
+		}
+		break;
 	case AST_CONTROL_HOLD:
 		ast_moh_start(c, data, NULL);
-		if (token)
-			free(token);
-		return 0;
+		res = 0;
+		break;
 	case AST_CONTROL_UNHOLD:
 		ast_moh_stop(c);
-		if (token)
-			free(token);
-		return 0;
+		res = 0;
+		break;
 	case AST_CONTROL_PROCEEDING:
 	case -1:
-		if (token)
-			free(token);
-		return -1;
+		break;
 	default:
-		ast_log(LOG_WARNING, "Don't know how to indicate condition %d on %s\n", condition, token);
-		if (token)
-			free(token);
-		return -1;
+		ast_log(LOG_WARNING, "OH323: Don't know how to indicate condition %d on %s\n", condition, token);
+		break;
 	}
 
 	if (h323debug)
-		ast_log(LOG_DEBUG, "OH323: Indicated %d on %s\n", condition, token);
+		ast_log(LOG_DEBUG, "OH323: Indicated %d on %s, res=%d\n", condition, token, res);
 	if (token)
 		free(token);
 	oh323_update_info(c);



More information about the asterisk-commits mailing list