[asterisk-commits] jcollie: branch jcollie/manager-flags r39315 - in /team/jcollie/manager-flags...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Aug 8 06:04:47 MST 2006


Author: jcollie
Date: Tue Aug  8 08:04:46 2006
New Revision: 39315

URL: http://svn.digium.com/view/asterisk?rev=39315&view=rev
Log:
Merged revisions 39272,39274,39295 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r39272 | russell | 2006-08-08 01:32:04 -0500 (Tue, 08 Aug 2006) | 56 lines

Merge team/russell/ast_verbose_threadstorage

- instead of defining a free() wrapper in a bunch of files, define it as
  ast_free() in utils.h and remove the copies from all the files.

- centralize and abstract the code used for doing thread storage. The code
  lives in threadstorage.h, with one function being implemented in utils.c.
  This new API includes generic thread storage as well as special functions
  for handling thread local dynamic length string buffers.

- update ast_inet_ntoa() to use the new threadstorage API
- update ast_state2str() to use the new threadstorage API
- update ast_cli() to use the new threadstorage API

- Modify manager_event() to use thread storage. Instead of using a buffer of
  4096 characters as the workspace for building the manager event, use a thread
  local dynamic string.  Now there is no length limitation on the length of the
  body of a manager event.

- Significantly simplify the handling of ast_verbose() ...
  - Instead of using a static char buffer and a lock to make sure only one
    thread can be using ast_verbose() at a time, use a thread local dynamic
    string as the workspace for preparing the verbose message. Instead of
    locking around the entire function, the only locking done now is when the
    message has been built and is being deliviered to the list of registered
    verbose message handlers.
  - This function was doing a strdup() on every message passed to it and
    keeping a queue of the last 200 messages in memory. This has been
    completely removed. The only place this was used was that if there were
    any messages in the verbose queue when a verbose handler was registered,
    all of the messages in the queue would be fed to it.  So, I just made sure
    that the console verbose handler and the network verbose handler (for
    remote asterisk consoles) were registered before any verbose messages.
    pbx_gtkconsole and pbx_kdeconsole will now lose a few verbose messages at
    startup, but I didn't feel the performance hit of this message queue was
    worth saving the initial verbose output for these very rarely used modules.
  - I have removed the last three arguments to the verbose handlers, leaving
    only the string itself because they aren't needed anymore. For example,
    ast_verbose had some logic for telling the verbose handler to add
    a newline if the buffer was completely full. Now that the buffer can grow
    as needed, this doesn't matter anymore.
  - remove unused function, ast_verbose_dmesg() which was to dispatch the
    message queue
  - Convert the list of verbose handlers to use the linked list macros.

- add missing newline characters to a few ast_verbose() calls

- convert the list of log channels to use the linked list macros in logger.c

- fix close_logger() to close all of the files it opened for logging

- update ast_log() to use a thread local dynamic string for its workspace
  for preparing log messages instead of a buffer of size BUFSIZ (8kB on my
  system) allocated on the stack.  The dynamic string in this case is limited
  to only growing to a maximum size of BUFSIZ.

........
r39274 | russell | 2006-08-08 01:36:47 -0500 (Tue, 08 Aug 2006) | 3 lines

change constant name from MAXSTRLEN to INITLEN since it is not the maximum
length, it is the initial length of the string when first allocated

........
r39295 | crichter | 2006-08-08 04:19:06 -0500 (Tue, 08 Aug 2006) | 14 lines

* added possibility to change echocancel settings during calls
* removed the holded element from the chan_list struct, we know this from the 
  state already
* added a few tweaks to make HOLD/RETRIEVE work again (TRANSFER does not work
  yet)
* added possibility to debug mISDN frames via syslog
* added misdn_lib_port_is_blocked function to check if a port is blocked
* removed ec_training=1 from empty_bc, we don't use ec_training anymore
* removed unused misdn_lib_get_l2_status function
* added the nt bit to dummy misdn_bchannel objects
* setting bc->out_fac_type to FACILITY_NONE defaultly
* removed HANDLER_DEBUG stuff for better readability


........

Added:
    team/jcollie/manager-flags/include/asterisk/threadstorage.h
      - copied unchanged from r39295, trunk/include/asterisk/threadstorage.h
Modified:
    team/jcollie/manager-flags/   (props changed)
    team/jcollie/manager-flags/asterisk.c
    team/jcollie/manager-flags/channel.c
    team/jcollie/manager-flags/channels/chan_iax2.c
    team/jcollie/manager-flags/channels/chan_misdn.c
    team/jcollie/manager-flags/channels/chan_sip.c
    team/jcollie/manager-flags/channels/misdn/fac.c
    team/jcollie/manager-flags/channels/misdn/isdn_lib.c
    team/jcollie/manager-flags/channels/misdn/isdn_lib.h
    team/jcollie/manager-flags/channels/misdn/isdn_msg_parser.c
    team/jcollie/manager-flags/cli.c
    team/jcollie/manager-flags/include/asterisk/compiler.h
    team/jcollie/manager-flags/include/asterisk/logger.h
    team/jcollie/manager-flags/include/asterisk/utils.h
    team/jcollie/manager-flags/logger.c
    team/jcollie/manager-flags/manager.c
    team/jcollie/manager-flags/pbx/pbx_ael.c
    team/jcollie/manager-flags/pbx/pbx_config.c
    team/jcollie/manager-flags/res/res_agi.c
    team/jcollie/manager-flags/res/res_features.c
    team/jcollie/manager-flags/utils.c

Propchange: team/jcollie/manager-flags/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/jcollie/manager-flags/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Aug  8 08:04:46 2006
@@ -1,1 +1,1 @@
-/trunk:1-39253
+/trunk:1-39314

Modified: team/jcollie/manager-flags/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/manager-flags/asterisk.c?rev=39315&r1=39314&r2=39315&view=diff
==============================================================================
--- team/jcollie/manager-flags/asterisk.c (original)
+++ team/jcollie/manager-flags/asterisk.c Tue Aug  8 08:04:46 2006
@@ -746,23 +746,9 @@
 	ast_network_puts(string);
 }
 
-static void network_verboser(const char *s, int pos, int replace, int complete)
-	/* ARGUSED */
-{
-	if (replace) {
-		char *t;
-		if ((t = alloca(strlen(s) + 2))) {
-			sprintf(t, "\r%s", s);
-			if (complete)
-				ast_network_puts_mutable(t);
-		} else {
-			ast_log(LOG_ERROR, "Out of memory\n");
-			ast_network_puts_mutable(s);
-		}
-	} else {
-		if (complete)
-			ast_network_puts_mutable(s);
-	}
+static void network_verboser(const char *s)
+{
+	ast_network_puts_mutable(s);
 }
 
 static pthread_t lthread;
@@ -1203,29 +1189,25 @@
 	return NULL;
 }
 
-static void console_verboser(const char *s, int pos, int replace, int complete)
+static void console_verboser(const char *s)
 {
 	char tmp[80];
 	const char *c = NULL;
-	/* Return to the beginning of the line */
-	if (!pos) {
-		fprintf(stdout, "\r");
-		if ((c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_4)) ||
-			(c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_3)) ||
-			(c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_2)) ||
-			(c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_1)))
-			fputs(tmp, stdout);
-	}
-	if (c)
-		fputs(c + pos,stdout);
-	else
-		fputs(s + pos,stdout);
+
+	if ((c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_4)) ||
+	    (c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_3)) ||
+	    (c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_2)) ||
+	    (c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_1))) {
+		fputs(tmp, stdout);
+		fputs(c, stdout);
+	} else
+		fputs(s, stdout);
+
 	fflush(stdout);
-	if (complete) {
-		/* Wake up a poll()ing console */
-		if (ast_opt_console && consolethread != AST_PTHREADT_NULL)
-			pthread_kill(consolethread, SIGURG);
-	}
+	
+	/* Wake up a poll()ing console */
+	if (ast_opt_console && consolethread != AST_PTHREADT_NULL)
+		pthread_kill(consolethread, SIGURG);
 }
 
 static int ast_all_zeros(char *s)
@@ -2427,6 +2409,14 @@
 		}
 	}
 
+	if (ast_opt_console || option_verbose || (ast_opt_remote && !ast_opt_exec)) {
+		ast_register_verbose(console_verboser);
+		WELCOME_MESSAGE;
+	}
+
+	if (ast_opt_console && !option_verbose) 
+		ast_verbose("[ Booting...\n");
+
 	if (ast_opt_always_fork && (ast_opt_remote || ast_opt_console)) {
 		ast_log(LOG_WARNING, "'alwaysfork' is not compatible with console or remote console mode; ignored\n");
 		ast_clear_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK);
@@ -2443,7 +2433,7 @@
 	}
 
 	if (ast_opt_console && !option_verbose) 
-		ast_verbose("[ Reading Master Configuration ]");
+		ast_verbose("[ Reading Master Configuration ]\n");
 	ast_readconfig();
 
 	if (ast_opt_dump_core) {
@@ -2526,7 +2516,7 @@
 	fflush(stdout);
 
 	if (ast_opt_console && !option_verbose) 
-		ast_verbose("[ Initializing Custom Configuration Options ]");
+		ast_verbose("[ Initializing Custom Configuration Options ]\n");
 	/* custom config setup */
 	register_config_cli();
 	read_config_maps();
@@ -2548,8 +2538,6 @@
 				exit(0);
 			}
 			printf(term_quit());
-			ast_register_verbose(console_verboser);
-			WELCOME_MESSAGE;
 			ast_remotecontrol(NULL);
 			quit_handler(0, 0, 0, 0);
 			exit(0);
@@ -2597,15 +2585,6 @@
 	sigaddset(&sigs, SIGPIPE);
 	sigaddset(&sigs, SIGWINCH);
 	pthread_sigmask(SIG_BLOCK, &sigs, NULL);
-	if (ast_opt_console || option_verbose || ast_opt_remote)
-		ast_register_verbose(console_verboser);
-	/* Print a welcome message if desired */
-	if (option_verbose || ast_opt_console) {
-		WELCOME_MESSAGE;
-	}
-	if (ast_opt_console && !option_verbose) 
-		ast_verbose("[ Booting...");
-
 	signal(SIGURG, urg_handler);
 	signal(SIGINT, __quit_handler);
 	signal(SIGTERM, __quit_handler);

Modified: team/jcollie/manager-flags/channel.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/manager-flags/channel.c?rev=39315&r1=39314&r2=39315&view=diff
==============================================================================
--- team/jcollie/manager-flags/channel.c (original)
+++ team/jcollie/manager-flags/channel.c Tue Aug  8 08:04:46 2006
@@ -66,6 +66,7 @@
 #include "asterisk/transcap.h"
 #include "asterisk/devicestate.h"
 #include "asterisk/sha1.h"
+#include "asterisk/threadstorage.h"
 #include "asterisk/slinfactory.h"
 
 struct channel_spy_trans {
@@ -99,8 +100,7 @@
 
 unsigned long global_fin = 0, global_fout = 0;
 
-static pthread_key_t state2str_buf_key;
-static pthread_once_t state2str_buf_once = PTHREAD_ONCE_INIT;
+AST_THREADSTORAGE(state2str_threadbuf, state2str_threadbuf_init);
 #define STATE2STR_BUFSIZE   32
 
 struct chanlist {
@@ -167,15 +167,6 @@
 	{ AST_CAUSE_INTERWORKING, "INTERWORKING", "Interworking, unspecified" },
 };
 
-#ifdef __AST_DEBUG_MALLOC
-static void FREE(void *ptr)
-{
-	free(ptr);
-}
-#else
-#define FREE free
-#endif
-
 struct ast_variable *ast_channeltype_list(void)
 {
 	struct chanlist *cl;
@@ -500,11 +491,6 @@
 	return -1;
 }
 
-static void state2str_buf_key_create(void)
-{
-	pthread_key_create(&state2str_buf_key, FREE);
-}
- 
 /*! \brief Gives the string form of a given channel state */
 char *ast_state2str(int state)
 {
@@ -532,12 +518,8 @@
 	case AST_STATE_PRERING:
 		return "Pre-ring";
 	default:
-		pthread_once(&state2str_buf_once, state2str_buf_key_create);
-		if (!(buf = pthread_getspecific(state2str_buf_key))) {
-			if (!(buf = ast_malloc(STATE2STR_BUFSIZE)))
-				return NULL;
-			pthread_setspecific(state2str_buf_key, buf);
-		}
+		if (!(buf = ast_threadstorage_get(&state2str_threadbuf, STATE2STR_BUFSIZE)))
+			return "Unknown";
 		snprintf(buf, STATE2STR_BUFSIZE, "Unknown (%d)", state);
 		return buf;
 	}

Modified: team/jcollie/manager-flags/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/manager-flags/channels/chan_iax2.c?rev=39315&r1=39314&r2=39315&view=diff
==============================================================================
--- team/jcollie/manager-flags/channels/chan_iax2.c (original)
+++ team/jcollie/manager-flags/channels/chan_iax2.c Tue Aug  8 08:04:46 2006
@@ -711,15 +711,6 @@
 static AST_LIST_HEAD_STATIC(dynamic_list, iax2_thread);
 
 static void *iax2_process_thread(void *data);
-
-#ifdef __AST_DEBUG_MALLOC
-static void FREE(void *ptr)
-{
-	free(ptr);
-}
-#else
-#define FREE free
-#endif
 
 static void signal_condition(ast_mutex_t *lock, ast_cond_t *cond)
 {
@@ -5472,7 +5463,7 @@
 			if (onoff) {
 				if (!ast_exists_extension(NULL, regcontext, ext, 1, NULL))
 					ast_add_extension(regcontext, 1, ext, 1, NULL, NULL,
-							  "Noop", ast_strdup(peer->name), FREE, "IAX2");
+							  "Noop", ast_strdup(peer->name), ast_free, "IAX2");
 			} else
 				ast_context_remove_extension(regcontext, ext, 1, NULL);
 		}

Modified: team/jcollie/manager-flags/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/manager-flags/channels/chan_misdn.c?rev=39315&r1=39314&r2=39315&view=diff
==============================================================================
--- team/jcollie/manager-flags/channels/chan_misdn.c (original)
+++ team/jcollie/manager-flags/channels/chan_misdn.c Tue Aug  8 08:04:46 2006
@@ -142,11 +142,12 @@
 	int need_hangup;
 	int need_busy;
 	
-	int holded; 
 	int orginator;
 
 	int norxtone;
 	int notxtone; 
+
+	int toggle_ec;
 	
 	int incoming_early_audio;
 
@@ -336,6 +337,8 @@
 int add_out_calls(int port);
 int add_in_calls(int port);
 
+
+static int update_ec_config(struct misdn_bchannel *bc);
 
 /*************** Helpers *****************/
 
@@ -987,6 +990,13 @@
 			"  --> state: %s\n"
 			"  --> capability: %s\n"
 			"  --> echo_cancel: %d\n"
+#ifdef WITH_BEROEC
+			"  --> bnec_tail: %d\n"
+			"  --> bnec_nlp: %d\n"
+			"  --> bnec_ah: %d\n"
+			"  --> bnec_td: %d\n"
+			"  --> bnec_zerocoeff: %d\n"
+#endif
 			"  --> notone : rx %d tx:%d\n"
 			"  --> bc_hold: %d holded_bc :%d\n",
 			help->ast->name,
@@ -1000,6 +1010,14 @@
 			bc_state2str(bc->bc_state),
 			bearer2str(bc->capability),
 			bc->ec_enable,
+
+#ifdef WITH_BEROEC
+			bc->bnec_tail,
+			bc->bnec_nlp,
+			bc->bnec_ah,
+			bc->bnec_td,
+			bc->bnec_zero,
+#endif
 			help->norxtone,help->notxtone,
 			bc->holded, help->holded_bc?1:0
 			);
@@ -1205,9 +1223,11 @@
 			ast_cli(fd, "Toggling EchoCancel %s failed Channel does not exist\n", channame);
 			return 0; 
 		} else {
-			tmp->bc->ec_enable=tmp->bc->ec_enable?0:1;
-
-			if (tmp->bc->ec_enable) {
+			
+			tmp->toggle_ec=tmp->toggle_ec?0:1;
+
+			if (tmp->toggle_ec) {
+				update_ec_config(tmp->bc);
 				manager_ec_enable(tmp->bc);
 			} else {
 				manager_ec_disable(tmp->bc);
@@ -1649,6 +1669,44 @@
 
 
 
+static int update_ec_config(struct misdn_bchannel *bc)
+{
+	int ec;
+	int port=bc->port;
+		
+	misdn_cfg_get( port, MISDN_CFG_ECHOCANCEL, &ec, sizeof(int));
+	
+	if (ec == 1 ) {
+		bc->ec_enable=1;
+	} else if ( ec > 1 ) {
+		bc->ec_enable=1;
+		bc->ec_deftaps=ec;
+	}
+#ifdef WITH_ECHOTRAINING 
+	int ectr;
+	misdn_cfg_get( port, MISDN_CFG_ECHOTRAINING, &ectr, sizeof(int));
+	
+	if ( ectr >= 0 ) {
+		bc->ec_training=ectr;
+	}
+#endif
+
+#ifdef WITH_BEROEC
+	misdn_cfg_get(port, MISDN_CFG_BNECHOCANCEL,&bc->bnec_tail, sizeof(int));
+	misdn_cfg_get(port, MISDN_CFG_BNEC_ANTIHOWL, &bc->bnec_ah, sizeof(int));
+	misdn_cfg_get(port, MISDN_CFG_BNEC_NLP, &bc->bnec_nlp, sizeof(int));
+	misdn_cfg_get(port, MISDN_CFG_BNEC_TD, &bc->bnec_td, sizeof(int));
+	misdn_cfg_get(port, MISDN_CFG_BNEC_ADAPT, &bc->bnec_adapt, sizeof(int));
+	misdn_cfg_get(port, MISDN_CFG_BNEC_ZEROCOEFF, &bc->bnec_zero, sizeof(int));
+
+	if (bc->bnec_tail && bc->ec_enable) {
+		ast_log(LOG_WARNING,"Are you sure you wan't to mix BNEC with Zapec ? This might cause bad audio quality!\n");
+		bc->ec_enable=0;
+	}
+#endif
+	return 0;
+}
+
 
 static int read_config(struct chan_list *ch, int orig) {
 
@@ -1718,41 +1776,9 @@
 	misdn_cfg_get( bc->port, MISDN_CFG_CONTEXT, ch->context, sizeof(ch->context));
 	
 	ast_copy_string (ast->context,ch->context,sizeof(ast->context));	
-	{
-		int ec;
-		
-		misdn_cfg_get( port, MISDN_CFG_ECHOCANCEL, &ec, sizeof(int));
-		
-		if (ec == 1 ) {
-			bc->ec_enable=1;
-		} else if ( ec > 1 ) {
-			bc->ec_enable=1;
-			bc->ec_deftaps=ec;
-		}
-#ifdef WITH_ECHOTRAINING 
-		int ectr;
-		misdn_cfg_get( port, MISDN_CFG_ECHOTRAINING, &ectr, sizeof(int));
-		
-		if ( ectr >= 0 ) {
-			bc->ec_training=ectr;
-		}
-#endif
-
-#ifdef WITH_BEROEC
-		misdn_cfg_get(port, MISDN_CFG_BNECHOCANCEL,&bc->bnec_tail, sizeof(int));
-		misdn_cfg_get(port, MISDN_CFG_BNEC_ANTIHOWL, &bc->bnec_ah, sizeof(int));
-		misdn_cfg_get(port, MISDN_CFG_BNEC_NLP, &bc->bnec_nlp, sizeof(int));
-		misdn_cfg_get(port, MISDN_CFG_BNEC_TD, &bc->bnec_td, sizeof(int));
-		misdn_cfg_get(port, MISDN_CFG_BNEC_ADAPT, &bc->bnec_adapt, sizeof(int));
-		misdn_cfg_get(port, MISDN_CFG_BNEC_ZEROCOEFF, &bc->bnec_zero, sizeof(int));
-
-		if (bc->bnec_tail && bc->ec_enable) {
-			ast_log(LOG_WARNING,"Are you sure you wan't to mix BNEC with Zapec ? This might cause bad audio quality!\n");
-			bc->ec_enable=0;
-		}
-#endif
-	}
-	
+
+	update_ec_config(bc);
+
 	{
 		int eb3;
 		
@@ -2141,7 +2167,7 @@
 	
 	if (!ast || ! (p=MISDN_ASTERISK_TECH_PVT(ast) )) return -1;
 	
-	chan_misdn_log(1, p->bc?p->bc->port:0, "* IND: Got Fixup State:%s Holded:%d L3id:%x\n", misdn_get_ch_state(p), p->holded, p->l3id);
+	chan_misdn_log(1, p->bc?p->bc->port:0, "* IND: Got Fixup State:%s L3id:%x\n", misdn_get_ch_state(p), p->l3id);
 	
 	p->ast = ast ;
 	p->state=MISDN_CONNECTED;
@@ -2539,7 +2565,7 @@
 		return -1;
 	}
 	
-	if (ch->holded ) {
+	if (ch->state == MISDN_HOLDED) {
 		chan_misdn_log(7, ch->bc->port, "misdn_write: Returning because holded\n");
 		return 0;
 	}
@@ -3349,7 +3375,6 @@
 	ast_moh_stop(AST_BRIDGED_P(holded_chan->ast));
 
 	holded_chan->state=MISDN_CONNECTED;
-	holded_chan->holded=0;
 	misdn_lib_transfer(holded_chan->bc?holded_chan->bc:holded_chan->holded_bc);
 	ast_channel_masquerade(holded_chan->ast, AST_BRIDGED_P(tmp_ch->ast));
 }
@@ -3559,6 +3584,8 @@
 			case EVENT_SETUP:
 			case EVENT_DISCONNECT:
 			case EVENT_PORT_ALARM:
+			case EVENT_RETRIEVE:
+			case EVENT_NEW_BC:
 				break;
 			case EVENT_RELEASE_COMPLETE:
 				chan_misdn_log(1, bc->port, " --> no Ch, so we've already released.\n");
@@ -3620,6 +3647,15 @@
 		break;
 
 	case EVENT_NEW_BC:
+		if (!ch) {
+			ch=find_holded(cl_te,bc);
+		}
+		
+		if (!ch) {
+			ast_log(LOG_WARNING,"NEW_BC without chan_list?\n");
+			break;
+		}
+
 		if (bc)
 			ch->bc=(struct misdn_bchannel*)user_data;
 		break;
@@ -4147,7 +4183,8 @@
 			if  (ch->state == MISDN_CONNECTED ) {
 				misdn_transfer_bc(ch, holded_ch) ;
 			}
-			misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
+			hangup_chan(ch);
+			release_chan(bc);
 			break;
 		}
 		
@@ -4333,6 +4370,12 @@
 	/***************************/
 	case EVENT_RETRIEVE:
 	{
+		ch=find_holded(cl_te, bc);
+		if (!ch) {
+			ast_log(LOG_WARNING, "Found no Holded channel, cannot Retrieve\n");
+			misdn_lib_send_event(bc, EVENT_RETRIEVE_REJECT);
+			break;
+		}
 		struct ast_channel *hold_ast=AST_BRIDGED_P(ch->ast);
 		ch->state = MISDN_CONNECTED;
 		

Modified: team/jcollie/manager-flags/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/manager-flags/channels/chan_sip.c?rev=39315&r1=39314&r2=39315&view=diff
==============================================================================
--- team/jcollie/manager-flags/channels/chan_sip.c (original)
+++ team/jcollie/manager-flags/channels/chan_sip.c Tue Aug  8 08:04:46 2006
@@ -1538,15 +1538,6 @@
 	set_udptl_peer: sip_set_udptl_peer,
 };
 
-#ifdef __AST_DEBUG_MALLOC
-static void FREE(void *ptr)
-{
-	free(ptr);
-}
-#else
-#define FREE free
-#endif
-
 /*! \brief Convert transfer status to string */
 static char *referstatus2str(enum referstatus rstatus)
 {
@@ -2253,7 +2244,7 @@
 		}
 		if (onoff)
 			ast_add_extension(context, 1, ext, 1, NULL, NULL, "Noop",
-				 ast_strdup(peer->name), FREE, "SIP");
+				 ast_strdup(peer->name), ast_free, "SIP");
 		else
 			ast_context_remove_extension(context, ext, 1, NULL);
 	}

Modified: team/jcollie/manager-flags/channels/misdn/fac.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/manager-flags/channels/misdn/fac.c?rev=39315&r1=39314&r2=39315&view=diff
==============================================================================
--- team/jcollie/manager-flags/channels/misdn/fac.c (original)
+++ team/jcollie/manager-flags/channels/misdn/fac.c Tue Aug  8 08:04:46 2006
@@ -264,8 +264,8 @@
 {
 	int i, fac_len=0;
 	unsigned char facility[256];
-	
-	if (! (bc->nt) )
+
+	if (!bc->nt)
 	{
 		p = NULL;
 		if (qi->QI_ELEMENT(facility))
@@ -274,9 +274,9 @@
 	if (!p)
 		return;
 	
-	fac_len = p[0];
+	fac_len = p[0] & 0xff;
+
 	memcpy(facility, p+1, fac_len);
-	
 	
 	switch(facility[0]) {
 	case FACILITY_CENTREX:

Modified: team/jcollie/manager-flags/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/manager-flags/channels/misdn/isdn_lib.c?rev=39315&r1=39314&r2=39315&view=diff
==============================================================================
--- team/jcollie/manager-flags/channels/misdn/isdn_lib.c (original)
+++ team/jcollie/manager-flags/channels/misdn/isdn_lib.c Tue Aug  8 08:04:46 2006
@@ -11,6 +11,8 @@
  * the GNU General Public License
  */
 
+
+#include <syslog.h>
 #include "isdn_lib_intern.h"
 #include <mISDNuser/isdn_debug.h>
 
@@ -64,6 +66,17 @@
 	}
 	return -1;
 
+}
+
+int misdn_lib_is_port_blocked(int port)
+{	
+	struct misdn_stack *stack=get_misdn_stack();
+	for ( ; stack; stack=stack->next) {
+		if (stack->port == port) {
+			return stack->blocked;
+		}
+	}
+	return -1;
 }
 
 int misdn_lib_is_ptp(int port)
@@ -367,14 +380,12 @@
 	}
 	
 	frm->addr = (stack->upper_id | FLG_MSG_DOWN);
-
-	
 	frm->dinfo = bc->l3_id;
-  
 	frm->len = (dmsg->len) - mISDN_HEADER_LEN;
-	
+				
+	cb_log(4,stack->port,"Sending msg, prim:%x addr:%x dinfo:%x\n",frm->prim,frm->addr,frm->dinfo);
+
 	mISDN_write(midev, dmsg->data, dmsg->len, TIMEOUT_1SEC);
-  
 	free_msg(dmsg);
 
 	return 0;
@@ -528,8 +539,10 @@
 {
 	bc->bframe_len=0;
 	
+
+	bc->in_use= 0;
+
 	bc->channel = 0;
-	bc->in_use = 0;
 
 	bc->sending_complete = 0;
 
@@ -569,8 +582,10 @@
 	bc->ec_enable = 0;
 	bc->ec_deftaps = 128;
 	bc->ec_whenbridged = 0;
+
+#ifdef EC_TRAIN
 	bc->ec_training = 1;
-	
+#endif
 	
 	bc->orig=0;
   
@@ -605,6 +620,7 @@
 	bc->orig_dad[0] = 0;
 	
 	bc->fac_type=FACILITY_NONE;
+	bc->out_fac_type=FACILITY_NONE;
 	
 	bc->te_choose_channel = 0;
 
@@ -638,22 +654,15 @@
 	
 	manager_bchannel_deactivate(bc);
 
-#ifdef WITH_BEROEC
-	if (bc->ec)
-		beroec_destroy(bc->ec);
-	bc->ec=NULL;
-#endif
-
-	if ( misdn_cap_is_speech(bc->capability) && bc->ec_enable) {
-		manager_ec_disable(bc);
-	}
+
+	manager_ec_disable(bc);
+
 
 	mISDN_write_frame(stack->midev, buff, bc->layer_id|FLG_MSG_TARGET|FLG_MSG_DOWN, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
 	
 	/*mISDN_clear_stack(stack->midev, bc->b_stid);*/
 
 	
-
 	bc->b_stid = 0;
 	bc_state_change(bc, BCHAN_CLEANED);
 	
@@ -800,18 +809,6 @@
 	return 0;
 }
 
-int misdn_lib_get_l2_status(struct misdn_stack *stack)
-{
-	iframe_t act;
-	
-	act.prim = DL_ESTABLISH | REQUEST;
-
-	act.addr = (stack->upper_id | FLG_MSG_DOWN)  ;
-
-	act.dinfo = 0;
-	act.len = 0;
-	return mISDN_write(stack->midev, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC);
-}
 
 int misdn_lib_get_short_status(struct misdn_stack *stack)
 {
@@ -1043,7 +1040,6 @@
 		bc_state_change(bc,BCHAN_ERROR);
 		return(-EINVAL);
 	}
-
 
 	ret = mISDN_get_setstack_ind(midev, bc->layer_id);
 
@@ -1308,6 +1304,17 @@
 			 * up L1s*/
 			stack->l1link=0;
 		}
+ 		stack->l1link=0;
+ 		stack->l2link=0;
+#if 0	
+		if (!stack->nt) {
+ 			misdn_lib_get_short_status(stack);
+ 		} else {
+ 			misdn_lib_get_l1_up(stack);
+ 			if (!stack->ptp) misdn_lib_get_l1_up(stack);
+ 			misdn_lib_get_l2_up(stack);
+ 		}
+#endif
 
 		misdn_lib_get_short_status(stack);
 		misdn_lib_get_l1_up(stack);
@@ -1570,6 +1577,7 @@
 				memset (&dummybc,0,sizeof(dummybc));
 				dummybc.port=stack->port;
 				dummybc.l3_id=frm->dinfo;
+				dummybc.nt=stack->nt;
 				bc=&dummybc; 
 			}
       
@@ -1768,9 +1776,13 @@
 			struct misdn_bchannel *hold_bc=stack_holder_find(stack,bc->l3_id);
 
 			if (hold_bc) {
-				cb_event(EVENT_NEW_BC, hold_bc, bc);
+
 				cb_log(4, stack->port, "REMOVEING Holder\n");
 				stack_holder_remove(stack, hold_bc);
+
+				memcpy(bc,hold_bc,sizeof(struct misdn_bchannel));
+				cb_event(EVENT_NEW_BC, hold_bc, bc);
+
 				free(hold_bc);
 			}
 			
@@ -1923,6 +1935,7 @@
 				memset (&dummybc,0,sizeof(dummybc));
 				dummybc.port=stack->port;
 				dummybc.l3_id=hh->dinfo;
+				dummybc.nt=stack->nt;
 				bc=&dummybc; 
 			}
 	
@@ -2025,6 +2038,7 @@
 			memset (&dummybc,0,sizeof(dummybc));
 			dummybc.port=stack->port;
 			dummybc.l3_id=hh->dinfo;
+			dummybc.nt=stack->nt;
 			bc=&dummybc; 
 		}
 		if (bc ) {
@@ -2554,13 +2568,11 @@
 	
 	struct misdn_stack *stack=find_stack_by_addr(frm->addr);
 
-	
-	cb_log(4,stack?stack->port:0,"handle_frm: frm->addr:%x frm->prim:%x\n",frm->addr,frm->prim);
-	
-  
 	if (!stack || stack->nt) {
 		return 0;
 	}
+	
+	cb_log(4,stack?stack->port:0,"handle_frm: frm->addr:%x frm->prim:%x\n",frm->addr,frm->prim);
 
 	{
 		struct misdn_bchannel *bc;
@@ -2648,7 +2660,7 @@
 	int i ;
 	
 	if (!stack) return 0 ;
-  
+
 	switch (frm->prim) {
 	case PH_ACTIVATE | CONFIRM:
 	case PH_ACTIVATE | INDICATION:
@@ -3136,7 +3148,7 @@
 	cb_log(4, stack->port, " --> screen:%d --> pres:%d\n",
 			bc->screen, bc->pres);
 	
-	cb_log(4, stack->port, " --> addr:%x l3id:%x b_stid:%x layer_id:%x\n", bc->pid, bc->addr, bc->l3_id, bc->b_stid, bc->layer_id);
+	cb_log(4, stack->port, " --> addr:%x l3id:%x b_stid:%x layer_id:%x\n", bc->addr, bc->l3_id, bc->b_stid, bc->layer_id);
 	
 	cb_log(4, stack->port, " --> facility:%s out_facility:%s\n",fac2str(bc->fac_type),fac2str(bc->out_fac_type));
 
@@ -3200,6 +3212,9 @@
 
 	case EVENT_CONNECT:
 	case EVENT_RETRIEVE_ACKNOWLEDGE:
+
+		bc->holded=0;
+		
 		if (stack->nt) {
 			if (bc->channel <=0 ) { /*  else we have the channel already */
 				bc->channel = find_free_chan_in_stack(stack, bc, 0);
@@ -3212,48 +3227,36 @@
 			}
 			/* Its that i generate channels */
 		}
-		
+
 		ret=setup_bc(bc);
 		if (ret == -EINVAL) {
 			cb_log(0,bc->port,"send_event: setup_bc failed\n");
 		}
-		
-		if ( (event == EVENT_CONNECT ) && misdn_cap_is_speech(bc->capability) ) {
-			if ( *bc->crypt_key ) {
-				cb_log(4, stack->port,  " --> ENABLING BLOWFISH channel:%d oad%d:%s dad%d:%s \n", bc->channel, bc->onumplan,bc->oad, bc->dnumplan,bc->dad);
+
+		cb_log(0,bc->port,"After SETUP BC\n");
+
+		
+		if (misdn_cap_is_speech(bc->capability)) {
+			if ((event==EVENT_CONNECT)||(event==EVENT_RETRIEVE_ACKNOWLEDGE)) {
+				if ( *bc->crypt_key ) {
+					cb_log(4, stack->port,  " --> ENABLING BLOWFISH channel:%d oad%d:%s dad%d:%s \n", bc->channel, bc->onumplan,bc->oad, bc->dnumplan,bc->dad);
+					
+					manager_ph_control_block(bc,  BF_ENABLE_KEY, bc->crypt_key, strlen(bc->crypt_key) );
+				}
 				
-				manager_ph_control_block(bc,  BF_ENABLE_KEY, bc->crypt_key, strlen(bc->crypt_key) );
-			}
-			
-			if (!bc->nodsp) manager_ph_control(bc,  DTMF_TONE_START, 0);
-			
-			if (bc->ec_enable) manager_ec_enable(bc);
-
-#ifdef WITH_BEROEC
-			if (!bec_initialized) bc->bnec_tail=0;
-
-			if (bc->bnec_tail) {
-				bc->ec=beroec_new(bc->bnec_tail, BEROEC_SUBBAND, bc->bnec_ah,
-				bc->bnec_td, bc->bnec_zero, bc->bnec_adapt, bc->bnec_nlp);
-			}
-#endif
-
-
-			
-			if (bc->txgain != 0) {
-				cb_log(4, stack->port,  "--> Changing txgain to %d\n", bc->txgain);
-				manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
-			}
-			
-			if ( bc->rxgain != 0 ) {
-				cb_log(4, stack->port,  "--> Changing rxgain to %d\n", bc->rxgain);
-				manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
-			}
-			
-		}
-		
-		if (event == EVENT_RETRIEVE_ACKNOWLEDGE) {
-			cb_log(0,bc->port,"DO WE NEED TO DO SOMETHING HERE WITH THE BC ?\n");
+				if (!bc->nodsp) manager_ph_control(bc,  DTMF_TONE_START, 0);
+				manager_ec_enable(bc);
+				
+				if (bc->txgain != 0) {
+					cb_log(4, stack->port,  "--> Changing txgain to %d\n", bc->txgain);
+					manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
+				}
+				
+				if ( bc->rxgain != 0 ) {
+					cb_log(4, stack->port,  "--> Changing rxgain to %d\n", bc->rxgain);
+					manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
+				}
+			}
 		}
 		break;
 
@@ -3325,16 +3328,7 @@
 		
 		if (misdn_cap_is_speech(bc->capability)) {
 			if (  !bc->nodsp) manager_ph_control(bc,  DTMF_TONE_START, 0);
-			if (bc->ec_enable) manager_ec_enable(bc);
-#ifdef WITH_BEROEC
-			if (!bec_initialized) bc->bnec_tail=0;
-
-			if (bc->bnec_tail) {
-				bc->ec=beroec_new(bc->bnec_tail, BEROEC_SUBBAND, bc->bnec_ah,
-				bc->bnec_td, bc->bnec_zero, bc->bnec_adapt, bc->bnec_nlp);
-			}
-#endif
-
+			manager_ec_enable(bc);
 
 			if ( bc->txgain != 0 ) {
 				cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain);
@@ -3470,22 +3464,18 @@
 	}
 
 	if ( ((frm->addr | ISDN_PID_BCHANNEL_BIT )>> 28 ) == 0x5) {
-#ifdef MISDN_HANDLER_DEBUG
-		cb_log(0,0,"handle_bchan START\n");
+		if (handle_bchan(msg)) {
+			return 0 ;
+		}
+	}	
+
+#ifdef RECV_FRM_SYSLOG_DEBUG
+	syslog(LOG_NOTICE,"mISDN recv: P(%02d): ADDR:%x PRIM:%x DINFO:%x\n",stack->port, frm->addr, frm->prim, frm->dinfo);
 #endif
-		if (handle_bchan(msg)) {
-#ifdef MISDN_HANDLER_DEBUG
-			cb_log(0,0,"handle_bchan STOP\n");
-#endif
-			return 0 ;
-		}
-#ifdef MISDN_HANDLER_DEBUG
-		cb_log(0,0,"handle_bchan NOTSTOP\n");
-#endif	
-	}	
-	
+
 	if (handle_timers(msg)) 
 		return 0 ;
+
 	
 	if (handle_mgmt(msg)) 
 		return 0 ; 
@@ -3497,45 +3487,18 @@
 	if (handle_l1(msg)) 
 		return 0 ;
 	
-#ifdef MISDN_HANDLER_DEBUG
-	cb_log(0,0,"handle_frm_nt START\n");
-#endif
 	if (handle_frm_nt(msg)) {
-#ifdef MISDN_HANDLER_DEBUG
-		cb_log(0,0,"handle_frm_nt STOP\n");
-#endif
 		return 0;
 	}
-#ifdef MISDN_HANDLER_DEBUG
-	cb_log(0,0,"handle_frm_nt NOTSTOP\n");
-	
-	cb_log(0,0,"handle_frm START\n");
-#endif
-	
+
 	if (handle_frm(msg)) {
-#ifdef MISDN_HANDLER_DEBUG
-		cb_log(0,0,"handle_frm STOP\n");
-#endif
-		
 		return 0;
 	}
-#ifdef MISDN_HANDLER_DEBUG
-	cb_log(0,0,"handle_frm NOTSTOP\n");	
-	
-	cb_log(0,0,"handle_err START\n");
-#endif
-	
+
 	if (handle_err(msg)) {
-#ifdef MISDN_HANDLER_DEBUG
-		cb_log(0,0,"handle_err STOP\n");
-#endif
 		return 0 ;
 	}
-#ifdef MISDN_HANDLER_DEBUG
-	cb_log(0,0,"handle_err NOTSTOP\n");
-#endif
-
-	
+
 	cb_log(0, 0, "Unhandled Message: prim %x len %d from addr %x, dinfo %x on this port.\n",frm->prim, frm->len, frm->addr, frm->dinfo);		
 	free_msg(msg);
 	
@@ -3719,7 +3682,6 @@
 				} else {
 					iframe_t *frm = (iframe_t *)msg->data;
 					struct misdn_bchannel *bc = find_bc_by_l3id(stack, frm->dinfo);
-					cb_log(4,stack->port,"Sending msg, prim:%x addr:%x dinfo:%x\n",frm->prim,frm->addr,frm->dinfo);
 					if (bc) send_msg(glob_mgr->midev, bc, msg);
 				}
 			}
@@ -4128,6 +4090,8 @@
 
 	if (!holder->stack_holder) return;
 	
+	holder->stack_holder=0;
+	
 	cb_log(4,stack->port, "*HOLDER: remove %x\n",holder->l3_id);
 	if (!stack || ! stack->holding) return;
   
@@ -4210,29 +4174,58 @@
 
 	struct misdn_stack *stack=get_stack_by_bc(bc);
 	
-	cb_log(1, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d training:%d\n",bc->ec_deftaps, bc->ec_training);
-	
-	switch (bc->ec_deftaps) {
-	case 4:
-	case 8:
-	case 16:
-	case 32:
-	case 64:
-	case 128:
-	case 256:
-	case 512:
-	case 1024:
-		cb_log(4, stack->port, "Taps is %d\n",bc->ec_deftaps);
-		break;
-	default:
-		cb_log(0, stack->port, "Taps should be power of 2\n");
-		bc->ec_deftaps=128;
-	}
-
-	ec_arr[0]=bc->ec_deftaps;
-	ec_arr[1]=bc->ec_training;
-	
-	manager_ph_control_block(bc,  ECHOCAN_ON,  ec_arr, sizeof(ec_arr));
+	cb_log(1, stack?stack->port:0,"ec_enable\n");
+
+	if (!misdn_cap_is_speech(bc->capability)) {
+		cb_log(1, stack?stack->port:0, " --> no speech? cannot enable EC\n");
+		return;
+	}
+
+#ifdef WITH_BEROEC
+	if (bc->ec) {
+		cb_log(1, stack?stack->port:0, " --> EC already loaded\n");
+		return;
+	}
+
+	if (!bec_initialized) bc->bnec_tail=0;
+
+	if (bc->bnec_tail) {
+		bc->ec=beroec_new(bc->bnec_tail, BEROEC_SUBBAND,
+		bc->bnec_ah,
+		bc->bnec_td, bc->bnec_zero, bc->bnec_adapt, bc->bnec_nlp);
+	}	
+	return ;
+#endif
+
+	if (bc->ec_enable) {
+		cb_log(1, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d training:%d\n",bc->ec_deftaps, bc->ec_training);
+	
+		switch (bc->ec_deftaps) {
+		case 4:
+		case 8:
+		case 16:
+		case 32:
+		case 64:
+		case 128:
+		case 256:
+		case 512:
+		case 1024:
+			cb_log(4, stack->port, "Taps is %d\n",bc->ec_deftaps);
+			break;
+		default:
+			cb_log(0, stack->port, "Taps should be power of 2\n");
+			bc->ec_deftaps=128;
+		}
+	
+		ec_arr[0]=bc->ec_deftaps;
+#ifdef EC_TRAIN
+		ec_arr[1]=bc->ec_training;
+#else
+		ec_arr[1]=0;
+#endif
+		
+		manager_ph_control_block(bc,  ECHOCAN_ON,  ec_arr, sizeof(ec_arr));
+	}
 }
 
 
@@ -4241,8 +4234,24 @@
 {
 	struct misdn_stack *stack=get_stack_by_bc(bc);
 	
-	cb_log(1, stack?stack->port:0, "Sending Control ECHOCAN_OFF\n");
-	manager_ph_control(bc,  ECHOCAN_OFF, 0);
+	cb_log(1, stack?stack->port:0,"ec_disable\n");
+
+	if (!misdn_cap_is_speech(bc->capability)) {
+		cb_log(1, stack?stack->port:0, " --> no speech? cannot disable EC\n");
+		return;
+	}
+
+#ifdef WITH_BEROEC
+	if (bc->ec)
+		beroec_destroy(bc->ec);
+	bc->ec=NULL;
+	return;
+#endif
+
+	if ( bc->ec_enable) {
+		cb_log(1, stack?stack->port:0, "Sending Control ECHOCAN_OFF\n");
+		manager_ph_control(bc,  ECHOCAN_OFF, 0);
+	}
 }
 
 struct misdn_stack* get_misdn_stack() {
@@ -4367,7 +4376,11 @@
 	
 		Isdnl2Init(&stack->nst);
 		Isdnl3Init(&stack->nst);
-	}
-}
-
-
+
+		if (!stack->ptp)
+			misdn_lib_get_l1_up(stack);
+		misdn_lib_get_l2_up(stack);
+	}
+}
+
+

Modified: team/jcollie/manager-flags/channels/misdn/isdn_lib.h
URL: http://svn.digium.com/view/asterisk/team/jcollie/manager-flags/channels/misdn/isdn_lib.h?rev=39315&r1=39314&r2=39315&view=diff
==============================================================================
--- team/jcollie/manager-flags/channels/misdn/isdn_lib.h (original)
+++ team/jcollie/manager-flags/channels/misdn/isdn_lib.h Tue Aug  8 08:04:46 2006
@@ -410,6 +410,7 @@
 int misdn_lib_port_restart(int port);
 int misdn_lib_get_port_info(int port);
 
+int misdn_lib_is_port_blocked(int port);
 int misdn_lib_port_block(int port);
 int misdn_lib_port_unblock(int port);
 

Modified: team/jcollie/manager-flags/channels/misdn/isdn_msg_parser.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/manager-flags/channels/misdn/isdn_msg_parser.c?rev=39315&r1=39314&r2=39315&view=diff
==============================================================================
--- team/jcollie/manager-flags/channels/misdn/isdn_msg_parser.c (original)
+++ team/jcollie/manager-flags/channels/misdn/isdn_msg_parser.c Tue Aug  8 08:04:46 2006
@@ -879,7 +879,7 @@
 
 void parse_facility (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) 
 {
-
+//#define FACILITY_DECODE
 #ifdef FACILITY_DECODE
 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
 	FACILITY_t *facility=(FACILITY_t*)((unsigned long)(msg->data+HEADER_LEN)); 

Modified: team/jcollie/manager-flags/cli.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/manager-flags/cli.c?rev=39315&r1=39314&r2=39315&view=diff
==============================================================================
--- team/jcollie/manager-flags/cli.c (original)
+++ team/jcollie/manager-flags/cli.c Tue Aug  8 08:04:46 2006
@@ -48,62 +48,29 @@
 #include "asterisk/app.h"
 #include "asterisk/lock.h"
 #include "editline/readline/readline.h"
+#include "asterisk/threadstorage.h"
 
 extern unsigned long global_fin, global_fout;
 
-static pthread_key_t ast_cli_buf_key;
-static pthread_once_t ast_cli_buf_once = PTHREAD_ONCE_INIT;
+AST_THREADSTORAGE(ast_cli_buf, ast_cli_buf_init);
 
 /*! \brief Initial buffer size for resulting strings in ast_cli() */
-#define AST_CLI_MAXSTRLEN   256
-
-#ifdef __AST_DEBUG_MALLOC
-static void FREE(void *ptr)
-{
-	free(ptr);
-}
-#else
-#define FREE free
-#endif
-
-static void ast_cli_buf_key_create(void)
-{
-	pthread_key_create(&ast_cli_buf_key, FREE);
-}
+#define AST_CLI_INITLEN   256
 
 void ast_cli(int fd, char *fmt, ...)
 {
-	struct {
-		size_t len;
-		char str[0];
-	} *buf;
 	int res;
+	struct ast_dynamic_str *buf;
 	va_list ap;
 
-	pthread_once(&ast_cli_buf_once, ast_cli_buf_key_create);
-	if (!(buf = pthread_getspecific(ast_cli_buf_key))) {
-		if (!(buf = ast_malloc(AST_CLI_MAXSTRLEN + sizeof(*buf))))
-			return;
-		buf->len = AST_CLI_MAXSTRLEN;
-		pthread_setspecific(ast_cli_buf_key, buf);
-	}
+	if (!(buf = ast_dynamic_str_thread_get(&ast_cli_buf, AST_CLI_INITLEN)))
+		return;
 
 	va_start(ap, fmt);
-	res = vsnprintf(buf->str, buf->len, fmt, ap);
-	while (res >= buf->len) {
-		if (!(buf = ast_realloc(buf, (buf->len * 2) + sizeof(*buf)))) {
-			va_end(ap);
-			return;
-		}
-		buf->len *= 2;
-		pthread_setspecific(ast_cli_buf_key, buf);
-		va_end(ap);
-		va_start(ap, fmt);
-		res = vsnprintf(buf->str, buf->len, fmt, ap);
-	}
+	res = ast_dynamic_str_thread_set_va(&buf, 0, &ast_cli_buf, fmt, ap);
 	va_end(ap);
 
-	if (res > 0)
+	if (res != AST_DYNSTR_BUILD_FAILED)
 		ast_carefulwrite(fd, buf->str, strlen(buf->str), 100);
 }
 

Modified: team/jcollie/manager-flags/include/asterisk/compiler.h
URL: http://svn.digium.com/view/asterisk/team/jcollie/manager-flags/include/asterisk/compiler.h?rev=39315&r1=39314&r2=39315&view=diff
==============================================================================
--- team/jcollie/manager-flags/include/asterisk/compiler.h (original)
+++ team/jcollie/manager-flags/include/asterisk/compiler.h Tue Aug  8 08:04:46 2006
@@ -33,5 +33,6 @@
 #endif
 
 #define attribute_const __attribute__((const))
+#define attribute_unused __attribute__((unused))
 
 #endif /* _ASTERISK_COMPILER_H */

Modified: team/jcollie/manager-flags/include/asterisk/logger.h
URL: http://svn.digium.com/view/asterisk/team/jcollie/manager-flags/include/asterisk/logger.h?rev=39315&r1=39314&r2=39315&view=diff
==============================================================================
--- team/jcollie/manager-flags/include/asterisk/logger.h (original)
+++ team/jcollie/manager-flags/include/asterisk/logger.h Tue Aug  8 08:04:46 2006
@@ -77,9 +77,9 @@
 void ast_verbose(const char *fmt, ...)
 	__attribute__ ((format (printf, 1, 2)));
 
-int ast_register_verbose(void (*verboser)(const char *string, int opos, int replacelast, int complete));
-int ast_unregister_verbose(void (*verboser)(const char *string, int opos, int replacelast, int complete));
-int ast_verbose_dmesg(void (*verboser)(const char *string, int opos, int replacelast, int complete));
+int ast_register_verbose(void (*verboser)(const char *string));
+int ast_unregister_verbose(void (*verboser)(const char *string));
+
 void ast_console_puts(const char *string);
 
 void ast_console_puts_mutable(const char *string);

Modified: team/jcollie/manager-flags/include/asterisk/utils.h
URL: http://svn.digium.com/view/asterisk/team/jcollie/manager-flags/include/asterisk/utils.h?rev=39315&r1=39314&r2=39315&view=diff
==============================================================================
--- team/jcollie/manager-flags/include/asterisk/utils.h (original)
+++ team/jcollie/manager-flags/include/asterisk/utils.h Tue Aug  8 08:04:46 2006
@@ -35,6 +35,7 @@
 #include "asterisk/time.h"
 #include "asterisk/strings.h"
 #include "asterisk/logger.h"
+#include "asterisk/compiler.h"
 
 /*! \note
  \verbatim
@@ -272,6 +273,22 @@
 long int ast_random(void);
 #endif
 
+/*! 
+ * \brief free() wrapper
+ *
+ * ast_free should be used when a function pointer for free() needs to be passed
+ * as the argument to a function. Otherwise, astmm will cause seg faults.
+ */
+#ifdef __AST_DEBUG_MALLOC

[... 998 lines stripped ...]


More information about the asterisk-commits mailing list