[svn-commits] russell: branch russell/chan_refcount r82340 - in /team/russell/chan_refcount...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Sep 13 14:14:12 CDT 2007


Author: russell
Date: Thu Sep 13 14:14:11 2007
New Revision: 82340

URL: http://svn.digium.com/view/asterisk?view=rev&rev=82340
Log:
sync with trunk

Modified:
    team/russell/chan_refcount/   (props changed)
    team/russell/chan_refcount/CHANGES
    team/russell/chan_refcount/LICENSE
    team/russell/chan_refcount/apps/app_queue.c
    team/russell/chan_refcount/channels/chan_zap.c
    team/russell/chan_refcount/configs/zapata.conf.sample
    team/russell/chan_refcount/include/asterisk.h
    team/russell/chan_refcount/main/asterisk.c
    team/russell/chan_refcount/main/astobj2.c

Propchange: team/russell/chan_refcount/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/russell/chan_refcount/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Sep 13 14:14:11 2007
@@ -1,1 +1,1 @@
-/trunk:1-82323
+/trunk:1-82338

Modified: team/russell/chan_refcount/CHANGES
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/CHANGES?view=diff&rev=82340&r1=82339&r2=82340
==============================================================================
--- team/russell/chan_refcount/CHANGES (original)
+++ team/russell/chan_refcount/CHANGES Thu Sep 13 14:14:11 2007
@@ -220,6 +220,7 @@
     those carriers that transmit CID via dtmf after a polarity change.
   * CID matching information is now shown when doing 'dialplan show'.
   * Added zap show version CLI command to chan_zap.
+  * Added setvar support to zapata.conf channel entries.
 
 H.323 Changes
 -------------

Modified: team/russell/chan_refcount/LICENSE
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/LICENSE?view=diff&rev=82340&r1=82339&r2=82340
==============================================================================
--- team/russell/chan_refcount/LICENSE (original)
+++ team/russell/chan_refcount/LICENSE Thu Sep 13 14:14:11 2007
@@ -32,7 +32,7 @@
 would strongly encourage you to make the same exception that we do).
 
 Specific permission is also granted to link Asterisk with OpenSSL and
-OpenH323.
+OpenH323 and distribute the resulting binary files.
 
 In addition, Asterisk implements two management/control protocols: the
 Asterisk Manager Interface (AMI) and the Asterisk Gateway Interface

Modified: team/russell/chan_refcount/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_queue.c?view=diff&rev=82340&r1=82339&r2=82340
==============================================================================
--- team/russell/chan_refcount/apps/app_queue.c (original)
+++ team/russell/chan_refcount/apps/app_queue.c Thu Sep 13 14:14:11 2007
@@ -368,6 +368,7 @@
 	unsigned int strategy:3;
 	unsigned int maskmemberstatus:1;
 	unsigned int realtime:1;
+	unsigned int found:1;
 	int announcefrequency;              /*!< How often to announce their position */
 	int minannouncefrequency;           /*!< The minimum number of seconds between position announcements (def. 15) */
 	int periodicannouncefrequency;      /*!< How often to play periodic announcement */
@@ -795,6 +796,7 @@
 	q->sound_callerannounce[0] = '\0';	/* Default, don't announce the caller that he has been answered */
 	q->members = ao2_container_alloc(37, member_hash_fn, member_cmp_fn);
 	q->membercount = 0;
+	q->found = 1;
 	ast_copy_string(q->sound_next, "queue-youarenext", sizeof(q->sound_next));
 	ast_copy_string(q->sound_thereare, "queue-thereare", sizeof(q->sound_thereare));
 	ast_copy_string(q->sound_calls, "queue-callswaiting", sizeof(q->sound_calls));
@@ -1164,6 +1166,7 @@
 				ast_mutex_unlock(&q->lock);
 				return NULL;
 			} else {
+				ast_log(LOG_WARNING, "Static queue '%s' already exists. Not loading from realtime\n", q->name);
 				ast_mutex_unlock(&q->lock);
 				return q;
 			}
@@ -4074,8 +4077,10 @@
 	use_weight=0;
 	/* Mark all queues as dead for the moment */
 	AST_LIST_TRAVERSE(&queues, q, list) {
-		if(!q->realtime)
+		if(!q->realtime) {
 			q->dead = 1;
+			q->found = 0;
+		}
 	}
 
 	/* Chug through config file */
@@ -4113,6 +4118,13 @@
 			if (q) {
 				if (!new)
 					ast_mutex_lock(&q->lock);
+				/* Check if a queue with this name already exists */
+				if (q->found) {
+					ast_log(LOG_WARNING, "Queue '%s' already defined! Skipping!\n", cat);
+					if(!new)
+						ast_mutex_unlock(&q->lock);
+					continue;
+				}
 				/* Re-initialize the queue, and clear statistics */
 				init_queue(q);
 				if (!queue_keep_stats) 

Modified: team/russell/chan_refcount/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/channels/chan_zap.c?view=diff&rev=82340&r1=82339&r2=82340
==============================================================================
--- team/russell/chan_refcount/channels/chan_zap.c (original)
+++ team/russell/chan_refcount/channels/chan_zap.c Thu Sep 13 14:14:11 2007
@@ -604,6 +604,7 @@
 	int propconfno;					/*!< Propagated conference number */
 	ast_group_t callgroup;
 	ast_group_t pickupgroup;
+	struct ast_variable *vars;
 	int channel;					/*!< Channel Number or CRV */
 	int span;					/*!< Span number */
 	time_t guardtime;				/*!< Must wait this much time before using for new call */
@@ -2489,6 +2490,8 @@
 		ASTOBJ_UNREF(p->smdi_iface, ast_smdi_interface_destroy);
 	if (p->mwi_event_sub)
 		ast_event_unsubscribe(p->mwi_event_sub);
+	if (p->vars)
+		ast_variables_destroy(p->vars);
 	ast_mutex_destroy(&p->lock);
 	ast_free(p);
 	*pvt = NULL;
@@ -5492,6 +5495,7 @@
 	int x,y;
 	int features;
 	struct ast_str *chan_name;
+	struct ast_variable *v;
 	ZT_PARAMS ps;
 	if (i->subs[index].owner) {
 		ast_log(LOG_WARNING, "Channel %d already has a %s call\n", i->channel,subnames[index]);
@@ -5653,6 +5657,10 @@
 	zt_confmute(i, 0);
 	/* Configure the new channel jb */
 	ast_jb_configure(tmp, &global_jbconf);
+
+	for (v = i->vars ; v ; v = v->next)
+                pbx_builtin_setvar_helper(tmp, v->name, v->value);
+
 	if (startpbx) {
 		if (ast_pbx_start(tmp)) {
 			ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
@@ -7889,6 +7897,10 @@
 		tmp->group = conf.chan.group;
 		tmp->callgroup = conf.chan.callgroup;
 		tmp->pickupgroup= conf.chan.pickupgroup;
+		if (conf.chan.vars) {
+			tmp->vars = conf.chan.vars;
+			conf.chan.vars = NULL;
+		}
 		tmp->cid_rxgain = conf.chan.cid_rxgain;
 		tmp->rxgain = conf.chan.rxgain;
 		tmp->txgain = conf.chan.txgain;
@@ -10953,6 +10965,12 @@
 			ast_cli(fd, "Caller ID: %s\n", tmp->cid_num);
 			ast_cli(fd, "Calling TON: %d\n", tmp->cid_ton);
 			ast_cli(fd, "Caller ID name: %s\n", tmp->cid_name);
+			if (tmp->vars) {
+				struct ast_variable *v;
+				ast_cli(fd, "Variables:\n");
+				for (v = tmp->vars ; v ; v = v->next)
+					ast_cli(fd, "       %s = %s\n", v->name, v->value);
+			}
 			ast_cli(fd, "Destroy: %d\n", tmp->destroy);
 			ast_cli(fd, "InAlarm: %d\n", tmp->inalarm);
 			ast_cli(fd, "Signalling Type: %s\n", sig2str(tmp->sig));
@@ -12102,6 +12120,16 @@
 				confp->chan.pickupgroup = 0;
 			else
 				confp->chan.pickupgroup = ast_get_group(v->value);
+		} else if (!strcasecmp(v->name, "setvar")) {
+			char *varname = ast_strdupa(v->value), *varval = NULL;
+			struct ast_variable *tmpvar;
+			if (varname && (varval = strchr(varname, '='))) {
+				*varval++ = '\0';
+				if ((tmpvar = ast_variable_new(varname, varval, ""))) {
+					tmpvar->next = confp->chan.vars;
+					confp->chan.vars = tmpvar;
+				}
+			}
 		} else if (!strcasecmp(v->name, "immediate")) {
 			confp->chan.immediate = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "transfertobusy")) {

Modified: team/russell/chan_refcount/configs/zapata.conf.sample
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/configs/zapata.conf.sample?view=diff&rev=82340&r1=82339&r2=82340
==============================================================================
--- team/russell/chan_refcount/configs/zapata.conf.sample (original)
+++ team/russell/chan_refcount/configs/zapata.conf.sample Thu Sep 13 14:14:11 2007
@@ -395,6 +395,8 @@
 callgroup=1
 pickupgroup=1
 
+;setvar=CHANNEL=42             ; Channel variable to be set for all calls from this channel
+
 ;
 ; Specify whether the channel should be answered immediately or if the simple
 ; switch should provide dialtone, read digits, etc.

Modified: team/russell/chan_refcount/include/asterisk.h
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/include/asterisk.h?view=diff&rev=82340&r1=82339&r2=82340
==============================================================================
--- team/russell/chan_refcount/include/asterisk.h (original)
+++ team/russell/chan_refcount/include/asterisk.h Thu Sep 13 14:14:11 2007
@@ -88,6 +88,7 @@
 void threadstorage_init(void);			/*!< Provided by threadstorage.c */
 void ast_event_init(void);          /*!< Provided by event.c */
 int ast_device_state_engine_init(void); /*!< Provided by devicestate.c */
+int astobj2_init(void);				/*! Provided by astobj2.c */
 
 /* Many headers need 'ast_channel' to be defined */
 struct ast_channel;

Modified: team/russell/chan_refcount/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/main/asterisk.c?view=diff&rev=82340&r1=82339&r2=82340
==============================================================================
--- team/russell/chan_refcount/main/asterisk.c (original)
+++ team/russell/chan_refcount/main/asterisk.c Thu Sep 13 14:14:11 2007
@@ -2869,6 +2869,8 @@
 
 	threadstorage_init();
 
+	astobj2_init();
+
 	if (load_modules(1)) {		/* Load modules, pre-load only */
 		printf(term_quit());
 		exit(1);

Modified: team/russell/chan_refcount/main/astobj2.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/main/astobj2.c?view=diff&rev=82340&r1=82339&r2=82340
==============================================================================
--- team/russell/chan_refcount/main/astobj2.c (original)
+++ team/russell/chan_refcount/main/astobj2.c Thu Sep 13 14:14:11 2007
@@ -64,6 +64,11 @@
 	void *user_data[0];
 };
 
+#ifdef AST_DEVMODE
+#define AO2_DEBUG 1
+#endif
+
+#ifdef AO2_DEBUG
 struct ao2_stats {
 	volatile int total_objects;
 	volatile int total_mem;
@@ -73,6 +78,7 @@
 };
 
 static struct ao2_stats ao2;
+#endif
 
 #ifndef HAVE_BKTR	/* backtrace support */
 void ao2_bt(void) {}
@@ -133,7 +139,9 @@
 	if (p == NULL)
 		return -1;
 
+#ifdef AO2_DEBUG
 	ast_atomic_fetchadd_int(&ao2.total_locked, 1);
+#endif
 
 	return ast_mutex_lock(&p->priv_data.lock);
 }
@@ -175,7 +183,9 @@
 	if (p == NULL)
 		return -1;
 
+#ifdef AO2_DEBUG
 	ast_atomic_fetchadd_int(&ao2.total_locked, -1);
+#endif
 
 	return ast_mutex_unlock(&p->priv_data.lock);
 }
@@ -198,9 +208,12 @@
 
 	/* we modify with an atomic operation the reference counter */
 	ret = ast_atomic_fetchadd_int(&obj->priv_data.ref_counter, delta);
+	current_value = ret + delta;
+
+#ifdef AO2_DEBUG	
 	ast_atomic_fetchadd_int(&ao2.total_refs, delta);
-	current_value = ret + delta;
-	
+#endif
+
 	/* this case must never happen */
 	if (current_value < 0)
 		ast_log(LOG_ERROR, "refcount %d on object %p\n", current_value, user_data);
@@ -210,13 +223,15 @@
 			obj->priv_data.destructor_fn(user_data);
 
 		ast_mutex_destroy(&obj->priv_data.lock);
+#ifdef AO2_DEBUG
 		ast_atomic_fetchadd_int(&ao2.total_mem, - obj->priv_data.data_size);
+		ast_atomic_fetchadd_int(&ao2.total_objects, -1);
+#endif
 		/* for safety, zero-out the astobj2 header and also the
 		 * first word of the user-data, which we make sure is always
 		 * allocated. */
 		bzero(obj, sizeof(struct astobj2 *) + sizeof(void *) );
 		free(obj);
-		ast_atomic_fetchadd_int(&ao2.total_objects, -1);
 	}
 
 	return ret;
@@ -244,9 +259,12 @@
 	obj->priv_data.data_size = data_size;
 	obj->priv_data.ref_counter = 1;
 	obj->priv_data.destructor_fn = destructor_fn;	/* can be NULL */
+
+#ifdef AO2_DEBUG
 	ast_atomic_fetchadd_int(&ao2.total_objects, 1);
 	ast_atomic_fetchadd_int(&ao2.total_mem, data_size);
 	ast_atomic_fetchadd_int(&ao2.total_refs, 1);
+#endif
 
 	/* return a pointer to the user data */
 	return EXTERNAL_OBJ(obj);
@@ -326,8 +344,11 @@
 	c->n_buckets = n_buckets;
 	c->hash_fn = hash_fn ? hash_fn : hash_zero;
 	c->cmp_fn = cmp_fn;
+
+#ifdef AO2_DEBUG
 	ast_atomic_fetchadd_int(&ao2.total_containers, 1);
-	
+#endif
+
 	return c;
 }
 
@@ -604,7 +625,10 @@
 	struct ao2_container *c = _c;
 
 	ao2_callback(c, OBJ_UNLINK, cd_cb, NULL);
+
+#ifdef AO2_DEBUG
 	ast_atomic_fetchadd_int(&ao2.total_containers, -1);
+#endif
 }
 
 static int print_cb(void *obj, void *arg, int flag)
@@ -616,6 +640,7 @@
 	return 0;
 }
 
+#ifdef AO2_DEBUG
 /*
  * Print stats
  */
@@ -706,10 +731,13 @@
 	handle_astobj2_stats, "Print astobj2 statistics", },
 	{ { "astobj2", "test", NULL } , handle_astobj2_test, "Test astobj2", },
 };
-
-int astobj2_init(void);
+#endif /* AO2_DEBUG */
+
 int astobj2_init(void)
 {
+#ifdef AO2_DEBUG
 	ast_cli_register_multiple(cli_astobj2, ARRAY_LEN(cli_astobj2));
+#endif
+
 	return 0;
 }




More information about the svn-commits mailing list