[Asterisk-cvs] asterisk app.c, 1.34, 1.35 autoservice.c, 1.7, 1.8 channel.c, 1.148, 1.149 cli.c, 1.64, 1.65 indications.c, 1.19, 1.20 pbx.c, 1.180, 1.181

markster at lists.digium.com markster at lists.digium.com
Tue Dec 7 15:40:59 CST 2004


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

Modified Files:
	app.c autoservice.c channel.c cli.c indications.c pbx.c 
Log Message:
Big diet for struct ast_channel


Index: app.c
===================================================================
RCS file: /usr/cvsroot/asterisk/app.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- app.c	26 Oct 2004 02:21:43 -0000	1.34
+++ app.c	7 Dec 2004 20:38:43 -0000	1.35
@@ -364,9 +364,9 @@
 	if (params) {
 		ls = params;
 		if (ls->allowoverride)
-			chan->writeinterrupt = 1;
+			ast_set_flag(chan, AST_FLAG_WRITE_INT);
 		else
-			chan->writeinterrupt = 0;
+			ast_clear_flag(chan, AST_FLAG_WRITE_INT);
 		ls->origwfmt = chan->writeformat;
 		if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
 			ast_log(LOG_WARNING, "Unable to set '%s' to linear format (write)\n", chan->name);

Index: autoservice.c
===================================================================
RCS file: /usr/cvsroot/asterisk/autoservice.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- autoservice.c	8 Aug 2004 17:15:01 -0000	1.7
+++ autoservice.c	7 Dec 2004 20:38:43 -0000	1.8
@@ -147,7 +147,7 @@
 		pthread_kill(asthread, SIGURG);
 	ast_mutex_unlock(&autolock);
 	/* Wait for it to un-block */
-	while(chan->blocking)
+	while(ast_test_flag(chan, AST_FLAG_BLOCKING))
 		usleep(1000);
 	return res;
 }

Index: channel.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channel.c,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -d -r1.148 -r1.149
--- channel.c	7 Nov 2004 16:21:00 -0000	1.148
+++ channel.c	7 Dec 2004 20:38:43 -0000	1.149
@@ -331,7 +331,6 @@
 					tmp->pvt = pvt;
 					/* Initial state */
 					tmp->_state = AST_STATE_DOWN;
-					tmp->stack = -1;
 					tmp->streamid = -1;
 					tmp->appl = NULL;
 					tmp->data = NULL;
@@ -416,7 +415,7 @@
 	} else if (chan->timingfd > -1) {
 		ioctl(chan->timingfd, ZT_TIMERPING, &blah);
 #endif				
-	} else if (chan->blocking) {
+	} else if (ast_test_flag(chan, AST_FLAG_BLOCKING)) {
 		pthread_kill(chan->blocker, SIGURG);
 	}
 	ast_mutex_unlock(&chan->lock);
@@ -441,8 +440,8 @@
 {
 	int pre = 0;
 	if (chan) {
-		pre = chan->deferdtmf;
-		chan->deferdtmf = 1;
+		pre = ast_test_flag(chan, AST_FLAG_DEFER_DTMF);
+		ast_set_flag(chan, AST_FLAG_DEFER_DTMF);
 	}
 	return pre;
 }
@@ -450,7 +449,7 @@
 void ast_channel_undefer_dtmf(struct ast_channel *chan)
 {
 	if (chan)
-		chan->deferdtmf = 0;
+		ast_clear_flag(chan, AST_FLAG_DEFER_DTMF);
 }
 
 struct ast_channel *ast_channel_walk_locked(struct ast_channel *prev)
@@ -666,7 +665,7 @@
 	chan->_softhangup |= cause;
 	ast_queue_frame(chan, &f);
 	/* Interrupt any poll call or such */
-	if (chan->blocking)
+	if (ast_test_flag(chan, AST_FLAG_BLOCKING))
 		pthread_kill(chan->blocker, SIGURG);
 	return res;
 }
@@ -711,7 +710,7 @@
 	/* If this channel is one which will be masqueraded into something, 
 	   mark it as a zombie already, so we know to free it later */
 	if (chan->masqr) {
-		chan->zombie=1;
+		ast_set_flag(chan, AST_FLAG_ZOMBIE);
 		ast_mutex_unlock(&chan->lock);
 		return 0;
 	}
@@ -734,13 +733,13 @@
 		ast_cdr_post(chan->cdr);
 		ast_cdr_free(chan->cdr);
 	}
-	if (chan->blocking) {
+	if (ast_test_flag(chan, AST_FLAG_BLOCKING)) {
 		ast_log(LOG_WARNING, "Hard hangup called by thread %ld on %s, while fd "
 					"is blocked by thread %ld in procedure %s!  Expect a failure\n",
 					(long)pthread_self(), chan->name, (long)chan->blocker, chan->blockproc);
 		CRASH;
 	}
-	if (!chan->zombie) {
+	if (!ast_test_flag(chan, AST_FLAG_ZOMBIE)) {
 		if (option_debug)
 			ast_log(LOG_DEBUG, "Hanging up channel '%s'\n", chan->name);
 		if (chan->pvt->hangup)
@@ -793,7 +792,7 @@
 	int res = 0;
 	ast_mutex_lock(&chan->lock);
 	/* Stop if we're a zombie or need a soft hangup */
-	if (chan->zombie || ast_check_hangup(chan)) {
+	if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
 		ast_mutex_unlock(&chan->lock);
 		return -1;
 	}
@@ -827,7 +826,7 @@
 			chan->generator->release(chan, chan->generatordata);
 		chan->generatordata = NULL;
 		chan->generator = NULL;
-		chan->writeinterrupt = 0;
+		ast_clear_flag(chan, AST_FLAG_WRITE_INT);
 		ast_settimeout(chan, 0, NULL, NULL);
 	}
 	ast_mutex_unlock(&chan->lock);
@@ -1012,7 +1011,7 @@
 	res = poll(pfds, max, rms);
 	if (res < 0) {
 		for (x=0;x<n;x++) 
-			c[x]->blocking = 0;
+			ast_clear_flag(c[x], AST_FLAG_BLOCKING);
 		/* Simulate a timeout if we were interrupted */
 		if (errno != EINTR)
 			*ms = -1;
@@ -1029,7 +1028,7 @@
 		time(&now);
 	spoint = 0;
 	for (x=0;x<n;x++) {
-		c[x]->blocking = 0;
+		ast_clear_flag(c[x], AST_FLAG_BLOCKING);
 		if (havewhen && c[x]->whentohangup && (now > c[x]->whentohangup)) {
 			c[x]->_softhangup |= AST_SOFTHANGUP_TIMEOUT;
 			if (!winner)
@@ -1039,9 +1038,9 @@
 			if (c[x]->fds[y] > -1) {
 				if ((res = ast_fdisset(pfds, c[x]->fds[y], max, &spoint))) {
 					if (res & POLLPRI)
-						c[x]->exception = -1;
+						ast_set_flag(c[x], AST_FLAG_EXCEPTION);
 					else
-						c[x]->exception = 0;
+						ast_clear_flag(c[x], AST_FLAG_EXCEPTION);
 					c[x]->fdno = y;
 					winner = c[x];
 				}
@@ -1101,7 +1100,7 @@
 	struct ast_frame *f;
 	char result = 0;
 	/* Stop if we're a zombie or need a soft hangup */
-	if (c->zombie || ast_check_hangup(c)) 
+	if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) 
 		return -1;
 	/* Wait for a digit, no more than ms milliseconds total. */
 	while(ms && !result) {
@@ -1146,7 +1145,7 @@
 	int outfd;
 	int res;
 	/* Stop if we're a zombie or need a soft hangup */
-	if (c->zombie || ast_check_hangup(c)) 
+	if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) 
 		return -1;
 	/* Wait for a digit, no more than ms milliseconds total. */
 	while(ms) {
@@ -1218,14 +1217,14 @@
 	}
 
 	/* Stop if we're a zombie or need a soft hangup */
-	if (chan->zombie || ast_check_hangup(chan)) {
+	if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
 		if (chan->generator)
 			ast_deactivate_generator(chan);
 		ast_mutex_unlock(&chan->lock);
 		return NULL;
 	}
 
-	if (!chan->deferdtmf && !ast_strlen_zero(chan->dtmfq)) {
+	if (!ast_test_flag(chan, AST_FLAG_DEFER_DTMF) && !ast_strlen_zero(chan->dtmfq)) {
 		/* We have DTMF that has been deferred.  Return it now */
 		chan->dtmff.frametype = AST_FRAME_DTMF;
 		chan->dtmff.subclass = chan->dtmfq[0];
@@ -1241,8 +1240,8 @@
 		read(chan->pvt->alertpipe[0], &blah, sizeof(blah));
 	}
 #ifdef ZAPTEL_OPTIMIZATIONS
-	if ((chan->timingfd > -1) && (chan->fdno == AST_MAX_FDS - 2) && chan->exception) {
-		chan->exception = 0;
+	if ((chan->timingfd > -1) && (chan->fdno == AST_MAX_FDS - 2) && ast_test_flag(chan, AST_FLAG_EXCEPTION)) {
+		ast_clear_flag(chan, AST_FLAG_EXCEPTION);
 		blah = -1;
 		/* IF we can't get event, assume it's an expired as-per the old interface */
 		res = ioctl(chan->timingfd, ZT_GETEVENT, &blah);
@@ -1296,7 +1295,7 @@
 		}
 	} else {
 		chan->blocker = pthread_self();
-		if (chan->exception) {
+		if (ast_test_flag(chan, AST_FLAG_EXCEPTION)) {
 			if (chan->pvt->exception) 
 				f = chan->pvt->exception(chan);
 			else {
@@ -1304,7 +1303,7 @@
 				f = &null_frame;
 			}
 			/* Clear the exception flag */
-			chan->exception = 0;
+			ast_clear_flag(chan, AST_FLAG_EXCEPTION);
 		} else
 		if (chan->pvt->read)
 			f = chan->pvt->read(chan);
@@ -1358,7 +1357,7 @@
 		/* End the CDR if appropriate */
 		if (chan->cdr)
 			ast_cdr_end(chan->cdr);
-	} else if (chan->deferdtmf && f->frametype == AST_FRAME_DTMF) {
+	} else if (ast_test_flag(chan, AST_FLAG_DEFER_DTMF) && f->frametype == AST_FRAME_DTMF) {
 		if (strlen(chan->dtmfq) < sizeof(chan->dtmfq) - 2)
 			chan->dtmfq[strlen(chan->dtmfq)] = f->subclass;
 		else
@@ -1414,7 +1413,7 @@
 {
 	int res = -1;
 	/* Stop if we're a zombie or need a soft hangup */
-	if (chan->zombie || ast_check_hangup(chan)) 
+	if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) 
 		return -1;
 	ast_mutex_lock(&chan->lock);
 	if (chan->pvt->indicate)
@@ -1490,12 +1489,12 @@
 {
 	int res = 0;
 	/* Stop if we're a zombie or need a soft hangup */
-	if (chan->zombie || ast_check_hangup(chan)) 
+	if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) 
 		return -1;
 	CHECK_BLOCKING(chan);
 	if (chan->pvt->send_text)
 		res = chan->pvt->send_text(chan, text);
-	chan->blocking = 0;
+	ast_clear_flag(chan, AST_FLAG_BLOCKING);
 	return res;
 }
 
@@ -1581,7 +1580,7 @@
 	struct ast_frame *f = NULL;
 	/* Stop if we're a zombie or need a soft hangup */
 	ast_mutex_lock(&chan->lock);
-	if (chan->zombie || ast_check_hangup(chan))  {
+	if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan))  {
 		ast_mutex_unlock(&chan->lock);
 		return -1;
 	}
@@ -1598,7 +1597,7 @@
 		return 0;
 	}
 	if (chan->generatordata) {
-		if (chan->writeinterrupt)
+		if (ast_test_flag(chan, AST_FLAG_WRITE_INT))
 			ast_deactivate_generator(chan);
 		else {
 			ast_mutex_unlock(&chan->lock);
@@ -1614,7 +1613,7 @@
 		ast_log(LOG_WARNING, "Don't know how to handle control frames yet\n");
 		break;
 	case AST_FRAME_DTMF:
-		chan->blocking = 0;
+		ast_clear_flag(chan, AST_FLAG_BLOCKING);
 		ast_mutex_unlock(&chan->lock);
 		res = do_senddigit(chan,fr->subclass);
 		ast_mutex_lock(&chan->lock);
@@ -1668,7 +1667,7 @@
 	}
 	if (f && (f != fr))
 		ast_frfree(f);
-	chan->blocking = 0;
+	ast_clear_flag(chan, AST_FLAG_BLOCKING);
 	/* Consider a write failure to force a soft hangup */
 	if (res < 0)
 		chan->_softhangup |= AST_SOFTHANGUP_DEV;
@@ -1992,7 +1991,7 @@
 	int res = -1;
 	/* Stop if we're a zombie or need a soft hangup */
 	ast_mutex_lock(&chan->lock);
-	if (!chan->zombie && !ast_check_hangup(chan)) 
+	if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) 
 		if (chan->pvt->call)
 			res = chan->pvt->call(chan, addr, timeout);
 	ast_mutex_unlock(&chan->lock);
@@ -2007,7 +2006,7 @@
 	int res = -1;
 	/* Stop if we're a zombie or need a soft hangup */
 	ast_mutex_lock(&chan->lock);
-	if (!chan->zombie && !ast_check_hangup(chan)) {
+	if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) {
 		if (chan->pvt->transfer) {
 			res = chan->pvt->transfer(chan, dest);
 			if (!res)
@@ -2026,7 +2025,7 @@
 	char d;
 	/* XXX Merge with full version? XXX */
 	/* Stop if we're a zombie or need a soft hangup */
-	if (c->zombie || ast_check_hangup(c)) 
+	if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) 
 		return -1;
 	if (!len)
 		return -1;
@@ -2064,7 +2063,7 @@
 	int to = ftimeout;
 	char d;
 	/* Stop if we're a zombie or need a soft hangup */
-	if (c->zombie || ast_check_hangup(c)) 
+	if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) 
 		return -1;
 	if (!len)
 		return -1;
@@ -2352,7 +2351,7 @@
 	/* XXX What about blocking, softhangup, blocker, and lock and blockproc? XXX */
 	/* Application and data remain the same */
 	/* Clone exception  becomes real one, as with fdno */
-	original->exception = clone->exception;
+	ast_copy_flags(original, clone, AST_FLAG_EXCEPTION);
 	original->fdno = clone->fdno;
 	/* Schedule context remains the same */
 	/* Stream stuff stays the same */
@@ -2398,19 +2397,19 @@
 	/* Now, at this point, the "clone" channel is totally F'd up.  We mark it as
 	   a zombie so nothing tries to touch it.  If it's already been marked as a
 	   zombie, then free it now (since it already is considered invalid). */
-	if (clone->zombie) {
+	if (ast_test_flag(clone, AST_FLAG_ZOMBIE)) {
 		ast_log(LOG_DEBUG, "Destroying clone '%s'\n", clone->name);
 		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;
+		ast_set_flag(clone, AST_FLAG_ZOMBIE);
 		ast_mutex_unlock(&clone->lock);
 	}
 	
 	/* Signal any blocker */
-	if (original->blocking)
+	if (ast_test_flag(original, AST_FLAG_BLOCKING))
 		pthread_kill(original->blocker, SIGURG);
 	ast_log(LOG_DEBUG, "Done Masquerading %s (%d)\n",
 		original->name, original->_state);
@@ -2576,7 +2575,7 @@
 		bridge_playfile(c1,c0,config->start_sound,time_left_ms / 1000);
 
 	/* Stop if we're a zombie or need a soft hangup */
-	if (c0->zombie || ast_check_hangup_locked(c0) || c1->zombie || ast_check_hangup_locked(c1)) 
+	if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) || ast_test_flag(c1, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1)) 
 		return -1;
 	if (c0->_bridge) {
 		ast_log(LOG_WARNING, "%s is already in a bridge with %s\n", 
@@ -2645,11 +2644,11 @@
 			
 		}
 		/* Stop if we're a zombie or need a soft hangup */
-		if (c0->zombie || ast_check_hangup_locked(c0) || c1->zombie || ast_check_hangup_locked(c1)) {
+		if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) || ast_test_flag(c1, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1)) {
 			*fo = NULL;
 			if (who) *rc = who;
 			res = 0;
-			ast_log(LOG_DEBUG, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n",c0->name,c1->name,c0->zombie?"Yes":"No",ast_check_hangup(c0)?"Yes":"No",c1->zombie?"Yes":"No",ast_check_hangup(c1)?"Yes":"No");
+			ast_log(LOG_DEBUG, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n",c0->name,c1->name,ast_test_flag(c0, AST_FLAG_ZOMBIE)?"Yes":"No",ast_check_hangup(c0)?"Yes":"No",ast_test_flag(c1, AST_FLAG_ZOMBIE)?"Yes":"No",ast_check_hangup(c1)?"Yes":"No");
 			break;
 		}
 		if (c0->pvt->bridge && config->timelimit==0 &&
@@ -2843,7 +2842,7 @@
 		ts->vol = td->vol;
 	}
 	/* Let interrupts interrupt :) */
-	chan->writeinterrupt = 1;
+	ast_set_flag(chan, AST_FLAG_WRITE_INT);
 	return ts;
 }
 

Index: cli.c
===================================================================
RCS file: /usr/cvsroot/asterisk/cli.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- cli.c	21 Nov 2004 17:02:04 -0000	1.64
+++ cli.c	7 Dec 2004 20:38:43 -0000	1.65
@@ -668,7 +668,6 @@
 	"   Pickup Group: %d\n"
 	"    Application: %s\n"
 	"           Data: %s\n"
-	"          Stack: %d\n"
 	"    Blocking in: %s\n",
 	c->name, c->type, c->uniqueid,
 	(c->cid.cid_num ? c->cid.cid_num : "(N/A)"),
@@ -679,7 +678,7 @@
 	hour, min, sec, 
 	c->context, c->exten, c->priority, c->callgroup, c->pickupgroup, ( c->appl ? c->appl : "(N/A)" ),
 	( c-> data ? (!ast_strlen_zero(c->data) ? c->data : "(Empty)") : "(None)"),
-	c->stack, (c->blocking ? c->blockproc : "(Not Blocking)"));
+	(ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)"));
 			if(pbx_builtin_serialize_variables(c,buf,sizeof(buf)))
 				ast_cli(fd,"Variables:\n%s\n",buf);
 

Index: indications.c
===================================================================
RCS file: /usr/cvsroot/asterisk/indications.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- indications.c	18 Jul 2004 15:58:57 -0000	1.19
+++ indications.c	7 Dec 2004 20:38:43 -0000	1.20
@@ -84,7 +84,10 @@
 		ps->items = pd->items;
 	}
 	/* Let interrupts interrupt :) */
-	chan->writeinterrupt = pd->interruptible;
+	if (pd->interruptible)
+		ast_set_flag(chan, AST_FLAG_WRITE_INT);
+	else
+		ast_clear_flag(chan, AST_FLAG_WRITE_INT);
 	return ps;
 }
 

Index: pbx.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx.c,v
retrieving revision 1.180
retrieving revision 1.181
diff -u -d -r1.180 -r1.181
--- pbx.c	2 Dec 2004 18:08:11 -0000	1.180
+++ pbx.c	7 Dec 2004 20:38:43 -0000	1.181
@@ -460,29 +460,9 @@
 	char *saved_c_appl;
 	char *saved_c_data;
 	
-	int stack = c->stack;
 	int (*execute)(struct ast_channel *chan, void *data) = app->execute; 
 
-	if (newstack && stack > AST_CHANNEL_MAX_STACK - 2) {
-		/* Don't allow us to go over the max number of stacks we
-		   permit saving. */
-		ast_log(LOG_WARNING, "Stack overflow, cannot create another stack\n");
-		return -1;
-	}
-	if (newstack && (res = setjmp(c->jmp[++c->stack]))) {
-		/* Okay, here's where it gets weird.  If newstack is non-zero, 
-		   then we increase the stack increment, but setjmp is not going
-		   to return until longjmp is called -- when the application
-		   exec'd is finished running. */
-		if (res == 1)
-			res = 0;
-		if (c->stack != stack + 1) 
-			ast_log(LOG_WARNING, "Stack returned to an unexpected place!\n");
-		else if (c->app[c->stack])
-			ast_log(LOG_WARNING, "Application may have forgotten to free its memory\n");
-		c->stack = stack;
-		return res;
-	} else {
+	if (newstack) {
 		if (c->cdr)
 			ast_cdr_setapp(c->cdr, app->name, data);
 
@@ -496,13 +476,10 @@
 		/* restore channel values */
 		c->appl= saved_c_appl;
 		c->data= saved_c_data;
-
-		/* Any application that returns, we longjmp back, just in case. */
-		if (c->stack != stack + 1)
-			ast_log(LOG_WARNING, "Stack is not at expected value\n");
-		longjmp(c->jmp[stack+1], res);
-		/* Never returns */
-	}
+		return res;
+	} else
+		ast_log(LOG_WARNING, "You really didn't want to call this function with newstack set to 0\n");
+	return -1;
 }
 
 




More information about the svn-commits mailing list