[Asterisk-cvs] asterisk app.c,1.10,1.11 channel.c,1.92,1.93 dsp.c,1.21,1.22 file.c,1.38,1.39 indications.c,1.13,1.14 pbx.c,1.110,1.111

markster at lists.digium.com markster at lists.digium.com
Tue Apr 6 18:17:05 CDT 2004


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv29122

Modified Files:
	app.c channel.c dsp.c file.c indications.c pbx.c 
Log Message:
Get rid of all that old needlock garbage now that we're using recursive mutexes


Index: app.c
===================================================================
RCS file: /usr/cvsroot/asterisk/app.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- app.c	27 Mar 2004 06:50:12 -0000	1.10
+++ app.c	6 Apr 2004 22:17:31 -0000	1.11
@@ -86,7 +86,7 @@
 			return res;
 	}
 	rfmt = c->readformat;
-	res = ast_set_read_format(c, AST_FORMAT_SLINEAR, 1);
+	res = ast_set_read_format(c, AST_FORMAT_SLINEAR);
 	if (res < 0) {
 		ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
 		return -1;
@@ -135,7 +135,7 @@
 			ast_frfree(f);
 		}
 	}
-	res = ast_set_read_format(c, rfmt, 1);
+	res = ast_set_read_format(c, rfmt);
 	if (res)
 		ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", c->name);
 	ast_dsp_free(sildet);

Index: channel.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channel.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -d -r1.92 -r1.93
--- channel.c	2 Apr 2004 23:25:24 -0000	1.92
+++ channel.c	6 Apr 2004 22:17:31 -0000	1.93
@@ -360,7 +360,7 @@
 	return tmp;
 }
 
-int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int lock)
+int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
 {
 	struct ast_frame *f;
 	struct ast_frame *prev, *cur;
@@ -372,8 +372,7 @@
 		ast_log(LOG_WARNING, "Unable to duplicate frame\n");
 		return -1;
 	}
-	if (lock)
-		ast_mutex_lock(&chan->lock);
+	ast_mutex_lock(&chan->lock);
 	prev = NULL;
 	cur = chan->pvt->readq;
 	while(cur) {
@@ -389,8 +388,7 @@
 		} else {
 			ast_log(LOG_DEBUG, "Dropping voice to exceptionally long queue on %s\n", chan->name);
 			ast_frfree(f);
-			if (lock)
-				ast_mutex_unlock(&chan->lock);
+			ast_mutex_unlock(&chan->lock);
 			return 0;
 		}
 	}
@@ -409,23 +407,22 @@
 	} else if (chan->blocking) {
 		pthread_kill(chan->blocker, SIGURG);
 	}
-	if (lock)
-		ast_mutex_unlock(&chan->lock);
+	ast_mutex_unlock(&chan->lock);
 	return 0;
 }
 
-int ast_queue_hangup(struct ast_channel *chan, int lock)
+int ast_queue_hangup(struct ast_channel *chan)
 {
 	struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
 	chan->_softhangup |= AST_SOFTHANGUP_DEV;
-	return ast_queue_frame(chan, &f, lock);
+	return ast_queue_frame(chan, &f);
 }
 
-int ast_queue_control(struct ast_channel *chan, int control, int lock)
+int ast_queue_control(struct ast_channel *chan, int control)
 {
 	struct ast_frame f = { AST_FRAME_CONTROL, };
 	f.subclass = control;
-	return ast_queue_frame(chan, &f, lock);
+	return ast_queue_frame(chan, &f);
 }
 
 int ast_channel_defer_dtmf(struct ast_channel *chan)
@@ -595,7 +592,7 @@
 		ast_log(LOG_DEBUG, "Soft-Hanging up channel '%s'\n", chan->name);
 	/* Inform channel driver that we need to be hung up, if it cares */
 	chan->_softhangup |= cause;
-	ast_queue_frame(chan, &f, 0);
+	ast_queue_frame(chan, &f);
 	/* Interrupt any select call or such */
 	if (chan->blocking)
 		pthread_kill(chan->blocker, SIGURG);
@@ -630,7 +627,7 @@
 	   if someone is going to masquerade as us */
 	ast_mutex_lock(&chan->lock);
 	if (chan->masq) {
-		if (ast_do_masquerade(chan, 1)) 
+		if (ast_do_masquerade(chan)) 
 			ast_log(LOG_WARNING, "Failed to perform masquerade\n");
 	}
 
@@ -855,7 +852,7 @@
 			}
 		}
 		if (c[x]->masq) {
-			if (ast_do_masquerade(c[x], 1)) {
+			if (ast_do_masquerade(c[x])) {
 				ast_log(LOG_WARNING, "Masquerade failed\n");
 				*ms = -1;
 				ast_mutex_unlock(&c[x]->lock);
@@ -1057,7 +1054,7 @@
 	
 	ast_mutex_lock(&chan->lock);
 	if (chan->masq) {
-		if (ast_do_masquerade(chan, 1)) {
+		if (ast_do_masquerade(chan)) {
 			ast_log(LOG_WARNING, "Failed to perform masquerade\n");
 			f = NULL;
 		} else
@@ -1418,7 +1415,7 @@
 	}
 	/* Handle any pending masquerades */
 	if (chan->masq) {
-		if (ast_do_masquerade(chan, 1)) {
+		if (ast_do_masquerade(chan)) {
 			ast_log(LOG_WARNING, "Failed to perform masquerade\n");
 			ast_mutex_unlock(&chan->lock);
 			return -1;
@@ -1514,14 +1511,13 @@
 	return res;
 }
 
-int ast_set_write_format(struct ast_channel *chan, int fmts, int needlock)
+int ast_set_write_format(struct ast_channel *chan, int fmts)
 {
 	int fmt;
 	int native;
 	int res;
 	
-	if (needlock)
-		ast_mutex_lock(&chan->lock);
+	ast_mutex_lock(&chan->lock);
 	native = chan->nativeformats;
 	fmt = fmts;
 	
@@ -1529,8 +1525,7 @@
 	if (res < 0) {
 		ast_log(LOG_NOTICE, "Unable to find a path from %s to %s\n",
 			ast_getformatname(fmts), ast_getformatname(chan->nativeformats));
-		if (needlock)
-			ast_mutex_unlock(&chan->lock);
+		ast_mutex_unlock(&chan->lock);
 		return -1;
 	}
 	
@@ -1545,19 +1540,17 @@
 	chan->pvt->writetrans = ast_translator_build_path(chan->pvt->rawwriteformat, chan->writeformat);
 	if (option_debug)
 		ast_log(LOG_DEBUG, "Set channel %s to write format %s\n", chan->name, ast_getformatname(chan->writeformat));
-	if (needlock)
-		ast_mutex_unlock(&chan->lock);
+	ast_mutex_unlock(&chan->lock);
 	return 0;
 }
 
-int ast_set_read_format(struct ast_channel *chan, int fmts, int needlock)
+int ast_set_read_format(struct ast_channel *chan, int fmts)
 {
 	int fmt;
 	int native;
 	int res;
 	
-	if (needlock)
-		ast_mutex_lock(&chan->lock);
+	ast_mutex_lock(&chan->lock);
 	native = chan->nativeformats;
 	fmt = fmts;
 	/* Find a translation path from the native read format to one of the user's read formats */
@@ -1565,8 +1558,7 @@
 	if (res < 0) {
 		ast_log(LOG_NOTICE, "Unable to find a path from %s to %s\n",
 			ast_getformatname(chan->nativeformats), ast_getformatname(fmts));
-		if (needlock)
-			ast_mutex_unlock(&chan->lock);
+		ast_mutex_unlock(&chan->lock);
 		return -1;
 	}
 	
@@ -1582,8 +1574,7 @@
 	if (option_debug)
 		ast_log(LOG_DEBUG, "Set channel %s to read format %s\n", 
 			chan->name, ast_getformatname(chan->readformat));
-	if (needlock)
-		ast_mutex_unlock(&chan->lock);
+	ast_mutex_unlock(&chan->lock);
 	return 0;
 }
 
@@ -1952,13 +1943,13 @@
 		return -1;
 	}
 	/* Set read format on channel */
-	res = ast_set_read_format(chan, peerf, 1);
+	res = ast_set_read_format(chan, peerf);
 	if (res < 0) {
 		ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", chan->name, chanf);
 		return -1;
 	}
 	/* Set write format on peer channel */
-	res = ast_set_write_format(peer, peerf, 1);
+	res = ast_set_write_format(peer, peerf);
 	if (res < 0) {
 		ast_log(LOG_WARNING, "Unable to set write format on channel %s to %d\n", peer->name, peerf);
 		return -1;
@@ -1972,13 +1963,13 @@
 		return -1;
 	}
 	/* Set writeformat on channel */
-	res = ast_set_write_format(chan, chanf, 1);
+	res = ast_set_write_format(chan, chanf);
 	if (res < 0) {
 		ast_log(LOG_WARNING, "Unable to set write format on channel %s to %d\n", chan->name, chanf);
 		return -1;
 	}
 	/* Set read format on peer channel */
-	res = ast_set_read_format(peer, chanf, 1);
+	res = ast_set_read_format(peer, chanf);
 	if (res < 0) {
 		ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", peer->name, peerf);
 		return -1;
@@ -2005,8 +1996,8 @@
 	clone->masqr = original;
 	/* XXX can't really hold the lock here, but at the same time, it' s
 	   not really safe not to XXX */
-	ast_queue_frame(original, &null, 0);
-	ast_queue_frame(clone, &null, 0);
+	ast_queue_frame(original, &null);
+	ast_queue_frame(clone, &null);
 	ast_log(LOG_DEBUG, "Done planning to masquerade %s into the structure of %s\n", original->name, clone->name);
 	return 0;
 }
@@ -2019,7 +2010,7 @@
 	manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", tmp, chan->name, chan->uniqueid);
 }
 
-int ast_do_masquerade(struct ast_channel *original, int needlock)
+int ast_do_masquerade(struct ast_channel *original)
 {
 	int x,i;
 	int res=0;
@@ -2044,9 +2035,8 @@
 	   channel's backend.   I'm not sure we're going to keep this function, because 
 	   while the features are nice, the cost is very high in terms of pure nastiness. XXX */
 
-	if (needlock)
-		/* We need the clone's lock, too */
-		ast_mutex_lock(&clone->lock);
+	/* We need the clone's lock, too */
+	ast_mutex_lock(&clone->lock);
 
 	ast_log(LOG_DEBUG, "Got clone lock on '%s' at %p\n", clone->name, &clone->lock);
 
@@ -2107,7 +2097,7 @@
 
 
 	if (clone->pvt->fixup){
-		res = clone->pvt->fixup(original, clone, needlock);
+		res = clone->pvt->fixup(original, clone);
 		if (res) 
 			ast_log(LOG_WARNING, "Fixup failed on channel %s, strange things may happen.\n", clone->name);
 	}
@@ -2117,8 +2107,7 @@
 		res = clone->pvt->hangup(clone);
 	if (res) {
 		ast_log(LOG_WARNING, "Hangup failed!  Strange things may happen!\n");
-		if (needlock)
-			ast_mutex_unlock(&clone->lock);
+		ast_mutex_unlock(&clone->lock);
 		return -1;
 	}
 	
@@ -2185,20 +2174,21 @@
 	/* pvt switches.  pbx stays the same, as does next */
 	
 	/* Set the write format */
-	ast_set_write_format(original, wformat, 0);
+	ast_set_write_format(original, wformat);
 
 	/* Set the read format */
-	ast_set_read_format(original, rformat, 0);
+	ast_set_read_format(original, rformat);
 
 	ast_log(LOG_DEBUG, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat);
 
 	/* Okay.  Last thing is to let the channel driver know about all this mess, so he
 	   can fix up everything as best as possible */
 	if (original->pvt->fixup) {
-		res = original->pvt->fixup(clone, original, needlock);
+		res = original->pvt->fixup(clone, original);
 		if (res) {
 			ast_log(LOG_WARNING, "Driver for '%s' could not fixup channel %s\n",
 				original->type, original->name);
+			ast_mutex_unlock(&clone->lock);
 			return -1;
 		}
 	} else
@@ -2210,15 +2200,13 @@
 	   zombie, then free it now (since it already is considered invalid). */
 	if (clone->zombie) {
 		ast_log(LOG_DEBUG, "Destroying clone '%s'\n", clone->name);
-		if (needlock)
-			ast_mutex_unlock(&clone->lock);
+		ast_mutex_unlock(&clone->lock);
 		ast_channel_free(clone);
 		manager_event(EVENT_FLAG_CALL, "Hangup", "Channel: %s\r\n", zombn);
 	} else {
 		ast_log(LOG_DEBUG, "Released clone lock on '%s'\n", clone->name);
 		clone->zombie=1;
-		if (needlock)
-			ast_mutex_unlock(&clone->lock);
+		ast_mutex_unlock(&clone->lock);
 	}
 	
 	/* Signal any blocker */
@@ -2484,7 +2472,7 @@
 {
 	struct tonepair_state *ts = params;
 	if (chan) {
-		ast_set_write_format(chan, ts->origwfmt, 0);
+		ast_set_write_format(chan, ts->origwfmt);
 	}
 	free(ts);
 }
@@ -2498,7 +2486,7 @@
 		return NULL;
 	memset(ts, 0, sizeof(struct tonepair_state));
 	ts->origwfmt = chan->writeformat;
-	if (ast_set_write_format(chan, AST_FORMAT_SLINEAR, 1)) {
+	if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
 		ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", chan->name);
 		tonepair_release(NULL, ts);
 		ts = NULL;

Index: dsp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/dsp.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- dsp.c	28 Mar 2004 02:53:03 -0000	1.21
+++ dsp.c	6 Apr 2004 22:17:31 -0000	1.22
@@ -1416,7 +1416,7 @@
 	return __ast_dsp_silence(dsp, s, len, totalsilence);
 }
 
-struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, struct ast_frame *af, int needlock)
+struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, struct ast_frame *af)
 {
 	int silence;
 	int res;
@@ -1508,7 +1508,7 @@
 					dsp->thinkdigit = 'x';
 					FIX_INF(af);
 					if (chan)
-						ast_queue_frame(chan, af, needlock);
+						ast_queue_frame(chan, af);
 					ast_frfree(af);
 					return &dsp->f;
 				}
@@ -1525,7 +1525,7 @@
 							dsp->f.subclass = dsp->thinkdigit;
 							FIX_INF(af);
 							if (chan)
-								ast_queue_frame(chan, af, needlock);
+								ast_queue_frame(chan, af);
 							ast_frfree(af);
 						}
 						dsp->thinkdigit = digit;
@@ -1547,7 +1547,7 @@
 						}
 						FIX_INF(af);
 						if (chan)
-							ast_queue_frame(chan, af, needlock);
+							ast_queue_frame(chan, af);
 						ast_frfree(af);
 						return &dsp->f;
 					}
@@ -1564,7 +1564,7 @@
 					dsp->td.mf.current_digits--;
 					FIX_INF(af);
 					if (chan)
-						ast_queue_frame(chan, af, needlock);
+						ast_queue_frame(chan, af);
 					ast_frfree(af);
 					return &dsp->f;
 				}
@@ -1577,7 +1577,7 @@
 					dsp->td.dtmf.current_digits--;
 					FIX_INF(af);
 					if (chan)
-						ast_queue_frame(chan, af, needlock);
+						ast_queue_frame(chan, af);
 					ast_frfree(af);
 					return &dsp->f;
 				}
@@ -1596,7 +1596,7 @@
 			case AST_CONTROL_CONGESTION:
 				dsp->f.subclass = res;
 				if (chan) 
-					ast_queue_frame(chan, &dsp->f, needlock);
+					ast_queue_frame(chan, &dsp->f);
 				break;
 			default:
 				ast_log(LOG_WARNING, "Don't know how to represent call progress message %d\n", res);

Index: file.c
===================================================================
RCS file: /usr/cvsroot/asterisk/file.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- file.c	27 Mar 2004 06:50:12 -0000	1.38
+++ file.c	6 Apr 2004 22:17:31 -0000	1.39
@@ -166,7 +166,7 @@
 		ast_closestream(tmp->vstream);
 	if (tmp->stream) {
 		ast_closestream(tmp->stream);
-		if (tmp->oldwriteformat && ast_set_write_format(tmp, tmp->oldwriteformat, 1))
+		if (tmp->oldwriteformat && ast_set_write_format(tmp, tmp->oldwriteformat))
 			ast_log(LOG_WARNING, "Unable to restore format back to %d\n", tmp->oldwriteformat);
 	}
 	return 0;
@@ -464,7 +464,7 @@
 	}
 	chan->oldwriteformat = chan->writeformat;
 	/* Set the channel to a format we can work with */
-	res = ast_set_write_format(chan, fmts, 1);
+	res = ast_set_write_format(chan, fmts);
 	
  	fd = ast_filehelper(filename2, (char *)chan, NULL, ACTION_OPEN);
 	if(fd >= 0)

Index: indications.c
===================================================================
RCS file: /usr/cvsroot/asterisk/indications.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- indications.c	27 Mar 2004 06:50:12 -0000	1.13
+++ indications.c	6 Apr 2004 22:17:31 -0000	1.14
@@ -58,7 +58,7 @@
 {
 	struct playtones_state *ps = params;
 	if (chan) {
-		ast_set_write_format(chan, ps->origwfmt, 0);
+		ast_set_write_format(chan, ps->origwfmt);
 	}
 	if (ps->items) free(ps->items);
 	free(ps);
@@ -72,7 +72,7 @@
 		return NULL;
 	memset(ps, 0, sizeof(struct playtones_state));
 	ps->origwfmt = chan->writeformat;
-	if (ast_set_write_format(chan, AST_FORMAT_SLINEAR, 1)) {
+	if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
 		ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", chan->name);
 		playtones_release(NULL, ps);
 		ps = NULL;

Index: pbx.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- pbx.c	6 Apr 2004 04:14:19 -0000	1.110
+++ pbx.c	6 Apr 2004 22:17:31 -0000	1.111
@@ -2842,21 +2842,21 @@
 	return tmp;
 }
 
-void __ast_context_destroy(struct ast_context *con, char *registrar, int lock);
+void __ast_context_destroy(struct ast_context *con, char *registrar);
 
 void ast_merge_contexts_and_delete(struct ast_context **extcontexts, char *registrar) {
 	struct ast_context *tmp, *lasttmp = NULL;
 	tmp = *extcontexts;
 	ast_mutex_lock(&conlock);
 	if (registrar) {
-		__ast_context_destroy(NULL,registrar,0);
+		__ast_context_destroy(NULL,registrar);
 		while (tmp) {
 			lasttmp = tmp;
 			tmp = tmp->next;
 		}
 	} else {
 		while (tmp) {
-			__ast_context_destroy(tmp,tmp->registrar,0);
+			__ast_context_destroy(tmp,tmp->registrar);
 			lasttmp = tmp;
 			tmp = tmp->next;
 		}
@@ -3517,11 +3517,10 @@
 	return -1;
 }
 
-int ast_async_goto(struct ast_channel *chan, char *context, char *exten, int priority, int needlock)
+int ast_async_goto(struct ast_channel *chan, char *context, char *exten, int priority)
 {
 	int res = 0;
-	if (needlock)
-		ast_mutex_lock(&chan->lock);
+	ast_mutex_lock(&chan->lock);
 	if (chan->pbx) {
 		/* This channel is currently in the PBX */
 		if (context && strlen(context))
@@ -3531,8 +3530,7 @@
 		if (priority)
 			chan->priority = priority - 1;
 		ast_softhangup_nolock(chan, AST_SOFTHANGUP_ASYNCGOTO);
-		if (needlock)
-			ast_mutex_unlock(&chan->lock);
+		ast_mutex_unlock(&chan->lock);
 	} else {
 		/* In order to do it when the channel doesn't really exist within
 		   the PBX, we have to make a new channel, masquerade, and start the PBX
@@ -3562,12 +3560,11 @@
 			/* Masquerade into temp channel */
 			ast_channel_masquerade(tmpchan, chan);
 		
-			if (needlock)
-				ast_mutex_unlock(&chan->lock);
+			ast_mutex_unlock(&chan->lock);
 
 			/* Grab the locks and get going */
 			ast_mutex_lock(&tmpchan->lock);
-			ast_do_masquerade(tmpchan, 0);
+			ast_do_masquerade(tmpchan);
 			ast_mutex_unlock(&tmpchan->lock);
 			/* Start the PBX going on our stolen channel */
 			if (ast_pbx_start(tmpchan)) {
@@ -3577,8 +3574,7 @@
 			}
 		} else {
 			res = -1;
-			if (needlock)
-				ast_mutex_unlock(&chan->lock);
+			ast_mutex_unlock(&chan->lock);
 		}
 	}
 	return res;
@@ -3594,7 +3590,7 @@
 		chan = ast_channel_walk(chan);
 	}
 	if (chan)
-		return ast_async_goto(chan, context, exten, priority, 1);
+		return ast_async_goto(chan, context, exten, priority);
 	return -1;
 }
 
@@ -4087,15 +4083,14 @@
 	free(e);
 }
 
-void __ast_context_destroy(struct ast_context *con, char *registrar, int lock)
+void __ast_context_destroy(struct ast_context *con, char *registrar)
 {
 	struct ast_context *tmp, *tmpl=NULL;
 	struct ast_include *tmpi, *tmpil= NULL;
 	struct ast_sw *sw, *swl= NULL;
 	struct ast_exten *e, *el, *en;
 	struct ast_ignorepat *ipi, *ipl = NULL;
-	if (lock)
-		ast_mutex_lock(&conlock);
+	ast_mutex_lock(&conlock);
 	tmp = contexts;
 	while(tmp) {
 		if (((tmp->name && con && con->name && !strcasecmp(tmp->name, con->name)) || !con) &&
@@ -4150,20 +4145,18 @@
 				tmpil = NULL;
 				continue;
 			}
-			if (lock)
-				ast_mutex_unlock(&conlock);
+			ast_mutex_unlock(&conlock);
 			return;
 		}
 		tmpl = tmp;
 		tmp = tmp->next;
 	}
-	if (lock)
-		ast_mutex_unlock(&conlock);
+	ast_mutex_unlock(&conlock);
 }
 
 void ast_context_destroy(struct ast_context *con, char *registrar)
 {
-	__ast_context_destroy(con,registrar,1);
+	__ast_context_destroy(con,registrar);
 }
 
 static void wait_for_hangup(struct ast_channel *chan)




More information about the svn-commits mailing list