[asterisk-commits] tilghman: branch tilghman/realtime_failover r176703 - in /team/tilghman/realt...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 17 15:56:08 CST 2009


Author: tilghman
Date: Tue Feb 17 15:56:08 2009
New Revision: 176703

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=176703
Log:
Merged revisions 176592,176627,176631-176632,176635,176639,176642,176666,176669 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
  r176592 | tilghman | 2009-02-17 12:49:20 -0600 (Tue, 17 Feb 2009) | 4 lines
  
  Add assertions in the quest to track down a refcount leak.
  (closes issue #14485)
   Reported by: davevg
................
  r176627 | russell | 2009-02-17 14:41:24 -0600 (Tue, 17 Feb 2009) | 37 lines
  
  Merge a large set of updates to the Asterisk indications API.
  
  This patch includes a number of changes to the indications API.  The primary
  motivation for this work was to improve stability.  The object management
  in this API was significantly flawed, and a number of trivial situations could
  cause crashes.
  
  The changes included are:
  
  1) Remove the module res_indications.  This included the critical functionality
     that actually loaded the indications configuration.  I have seen many people
     have Asterisk problems because they accidentally did not have an
     indications.conf present and loaded.  Now, this code is in the core,
     and Asterisk will fail to start without indications configuration.
  
     There was one part of res_indications, the dialplan applications, which did
     belong in a module, and have been moved to a new module, app_playtones.
  
  2) Object management has been significantly changed.  Tone zones are now
     managed using astobj2, and it is no longer possible to crash Asterisk by
     issuing a reload that destroys tone zones while they are in use.
  
  3) The API documentation has been filled out.
  
  4) The API has been updated to follow our naming conventions.
  
  5) Various bits of code throughout the tree have been updated to account
     for the API update.
  
  6) Configuration parsing has been mostly re-written.
  
  7) "Code cleanup"
  
  The code is from svn/asterisk/team/russell/indications/.
  
  Review: http://reviewboard.digium.com/r/149/
................
  r176631 | oej | 2009-02-17 14:50:03 -0600 (Tue, 17 Feb 2009) | 2 lines
  
  Typo
................
  r176632 | russell | 2009-02-17 14:51:10 -0600 (Tue, 17 Feb 2009) | 8 lines
  
  Add an implementation of the heap data structure.
  
  A heap is a convenient data structure for implementing a priority queue.
  
  Code from svn/asterisk/team/russell/heap/.
  
  Review: http://reviewboard.digium.com/r/160/
................
  r176635 | russell | 2009-02-17 14:56:26 -0600 (Tue, 17 Feb 2009) | 4 lines
  
  Add a test module for the heap implementation.
  
  Review: http://reviewboard.digium.com/r/160/
................
  r176639 | russell | 2009-02-17 15:04:08 -0600 (Tue, 17 Feb 2009) | 9 lines
  
  Significantly improve scheduler performance under high load.
  
  This patch changes the scheduler to use a max-heap to store pending scheduler
  entries instead of a fully sorted doubly linked list.  When the number of
  entries in the scheduler gets large, this will perform much better.  For much
  more detailed information on this change, see the review request.
  
  Review: http://reviewboard.digium.com/r/160/
................
  r176642 | tilghman | 2009-02-17 15:14:18 -0600 (Tue, 17 Feb 2009) | 8 lines
  
  Prior to masquerade, move the group definitions to the channel performing the
  masq, so that the group count lingers past the bridge.
  (closes issue #14275)
   Reported by: kowalma
   Patches: 
         20090216__bug14275.diff.txt uploaded by Corydon76 (license 14)
   Tested by: kowalma
................
  r176666 | russell | 2009-02-17 15:22:40 -0600 (Tue, 17 Feb 2009) | 16 lines
  
  Update the timing API to have better support for multiple timing interfaces.
  
  1) Add module use count handling so that timing modules can be unloaded.
  
  2) Implement unload_module() functions for the timing interface modules.
  
  3) Allow multiple timing modules to be loaded, and use the one with the
     highest priority value.
  
  4) Report which timing module is being use in the "timing test" CLI command.
  
  (closes issue #14489)
  Reported by: russell
  
  Review: http://reviewboard.digium.com/r/162/
................
  r176669 | tilghman | 2009-02-17 15:23:10 -0600 (Tue, 17 Feb 2009) | 16 lines
  
  Recorded merge of revisions 176661 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r176661 | tilghman | 2009-02-17 15:21:41 -0600 (Tue, 17 Feb 2009) | 9 lines
    
    Backport change to 1.4:
      Prior to masquerade, move the group definitions to the channel performing the
      masq, so that the group count lingers past the bridge.
      (closes issue #14275)
       Reported by: kowalma
       Patches: 
             20090216__bug14275.diff.txt uploaded by Corydon76 (license 14)
       Tested by: kowalma
  ........
................

Added:
    team/tilghman/realtime_failover/apps/app_playtones.c
      - copied unchanged from r176669, trunk/apps/app_playtones.c
    team/tilghman/realtime_failover/include/asterisk/heap.h
      - copied unchanged from r176669, trunk/include/asterisk/heap.h
    team/tilghman/realtime_failover/main/heap.c
      - copied unchanged from r176669, trunk/main/heap.c
    team/tilghman/realtime_failover/tests/test_heap.c
      - copied unchanged from r176669, trunk/tests/test_heap.c
    team/tilghman/realtime_failover/tests/test_sched.c
      - copied unchanged from r176669, trunk/tests/test_sched.c
Removed:
    team/tilghman/realtime_failover/res/res_indications.c
Modified:
    team/tilghman/realtime_failover/   (props changed)
    team/tilghman/realtime_failover/UPGRADE.txt
    team/tilghman/realtime_failover/apps/app_disa.c
    team/tilghman/realtime_failover/apps/app_read.c
    team/tilghman/realtime_failover/apps/app_readexten.c
    team/tilghman/realtime_failover/channels/chan_local.c
    team/tilghman/realtime_failover/channels/chan_misdn.c
    team/tilghman/realtime_failover/channels/chan_skinny.c
    team/tilghman/realtime_failover/channels/chan_unistim.c
    team/tilghman/realtime_failover/configs/indications.conf.sample
    team/tilghman/realtime_failover/funcs/func_channel.c
    team/tilghman/realtime_failover/funcs/func_odbc.c
    team/tilghman/realtime_failover/include/asterisk/_private.h
    team/tilghman/realtime_failover/include/asterisk/channel.h
    team/tilghman/realtime_failover/include/asterisk/config.h
    team/tilghman/realtime_failover/include/asterisk/indications.h
    team/tilghman/realtime_failover/include/asterisk/timing.h
    team/tilghman/realtime_failover/main/Makefile
    team/tilghman/realtime_failover/main/app.c
    team/tilghman/realtime_failover/main/asterisk.c
    team/tilghman/realtime_failover/main/channel.c
    team/tilghman/realtime_failover/main/config.c
    team/tilghman/realtime_failover/main/indications.c
    team/tilghman/realtime_failover/main/loader.c
    team/tilghman/realtime_failover/main/pbx.c
    team/tilghman/realtime_failover/main/sched.c
    team/tilghman/realtime_failover/main/timing.c
    team/tilghman/realtime_failover/res/res_odbc.c
    team/tilghman/realtime_failover/res/res_timing_dahdi.c
    team/tilghman/realtime_failover/res/res_timing_pthread.c
    team/tilghman/realtime_failover/res/res_timing_timerfd.c
    team/tilghman/realtime_failover/res/snmp/agent.c

Propchange: team/tilghman/realtime_failover/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/tilghman/realtime_failover/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/tilghman/realtime_failover/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Feb 17 15:56:08 2009
@@ -1,1 +1,1 @@
-/trunk:1-176587
+/trunk:1-176696

Modified: team/tilghman/realtime_failover/UPGRADE.txt
URL: http://svn.digium.com/svn-view/asterisk/team/tilghman/realtime_failover/UPGRADE.txt?view=diff&rev=176703&r1=176702&r2=176703
==============================================================================
--- team/tilghman/realtime_failover/UPGRADE.txt (original)
+++ team/tilghman/realtime_failover/UPGRADE.txt Tue Feb 17 15:56:08 2009
@@ -17,6 +17,13 @@
 === UPGRADE-1.6.txt -- Upgrade info for 1.4 to 1.6
 ===
 ===========================================================
+
+From 1.6.1 to 1.6.2:
+
+* The res_indications module has been removed.  Its functionality was important
+  enough that most of it has been moved into the Asterisk core.
+  Two applications previously provided by res_indications, PlayTones and
+  StopPlayTones, have been moved into a new module, app_playtones.
 
 From 1.6.0.1 to 1.6.1:
 

Modified: team/tilghman/realtime_failover/apps/app_disa.c
URL: http://svn.digium.com/svn-view/asterisk/team/tilghman/realtime_failover/apps/app_disa.c?view=diff&rev=176703&r1=176702&r2=176703
==============================================================================
--- team/tilghman/realtime_failover/apps/app_disa.c (original)
+++ team/tilghman/realtime_failover/apps/app_disa.c Tue Feb 17 15:56:08 2009
@@ -124,15 +124,20 @@
 
 static void play_dialtone(struct ast_channel *chan, char *mailbox)
 {
-	const struct tone_zone_sound *ts = NULL;
-	if(ast_app_has_voicemail(mailbox, NULL))
+	struct ast_tone_zone_sound *ts = NULL;
+
+	if (ast_app_has_voicemail(mailbox, NULL)) {
 		ts = ast_get_indication_tone(chan->zone, "dialrecall");
-	else
+	} else {
 		ts = ast_get_indication_tone(chan->zone, "dial");
-	if (ts)
+	}
+
+	if (ts) {
 		ast_playtones_start(chan, 0, ts->data, 0);
-	else
+		ts = ast_tone_zone_sound_unref(ts);
+	} else {
 		ast_tonepair_start(chan, 350, 440, 0, 0);
+	}
 }
 
 static int disa_exec(struct ast_channel *chan, void *data)

Modified: team/tilghman/realtime_failover/apps/app_read.c
URL: http://svn.digium.com/svn-view/asterisk/team/tilghman/realtime_failover/apps/app_read.c?view=diff&rev=176703&r1=176702&r2=176703
==============================================================================
--- team/tilghman/realtime_failover/apps/app_read.c (original)
+++ team/tilghman/realtime_failover/apps/app_read.c Tue Feb 17 15:56:08 2009
@@ -132,7 +132,7 @@
 	int tries = 1, to = 0, x = 0;
 	double tosec;
 	char *argcopy = NULL;
-	struct tone_zone_sound *ts = NULL;
+	struct ast_tone_zone_sound *ts = NULL;
 	struct ast_flags flags = {0};
 	const char *status = "ERROR";
 
@@ -188,7 +188,7 @@
 		return 0;
 	}
 	if (ast_test_flag(&flags, OPT_INDICATION)) {
-		if (! ast_strlen_zero(arglist.filename)) {
+		if (!ast_strlen_zero(arglist.filename)) {
 			ts = ast_get_indication_tone(chan->zone, arglist.filename);
 		}
 	}
@@ -258,6 +258,10 @@
 		}
 	}
 
+	if (ts) {
+		ts = ast_tone_zone_sound_unref(ts);
+	}
+
 	if (ast_check_hangup(chan))
 		status = "HANGUP";
 	pbx_builtin_setvar_helper(chan, "READSTATUS", status);

Modified: team/tilghman/realtime_failover/apps/app_readexten.c
URL: http://svn.digium.com/svn-view/asterisk/team/tilghman/realtime_failover/apps/app_readexten.c?view=diff&rev=176703&r1=176702&r2=176703
==============================================================================
--- team/tilghman/realtime_failover/apps/app_readexten.c (original)
+++ team/tilghman/realtime_failover/apps/app_readexten.c Tue Feb 17 15:56:08 2009
@@ -132,7 +132,7 @@
 	int maxdigits = sizeof(exten) - 1;
 	int timeout = 0, digit_timeout = 0, x = 0;
 	char *argcopy = NULL, *status = "";
-	struct tone_zone_sound *ts = NULL;
+	struct ast_tone_zone_sound *ts = NULL;
 	struct ast_flags flags = {0};
 
 	 AST_DECLARE_APP_ARGS(arglist,
@@ -179,8 +179,9 @@
 	if (digit_timeout <= 0)
 		digit_timeout = chan->pbx ? chan->pbx->dtimeoutms : 5000;
 
-	if (ast_test_flag(&flags, OPT_INDICATION) && !ast_strlen_zero(arglist.filename))
+	if (ast_test_flag(&flags, OPT_INDICATION) && !ast_strlen_zero(arglist.filename)) {
 		ts = ast_get_indication_tone(chan->zone, arglist.filename);
+	}
 
 	do {
 		if (chan->_state != AST_STATE_UP) {
@@ -250,6 +251,10 @@
 		}
 	} while (0);
 
+	if (ts) {
+		ts = ast_tone_zone_sound_unref(ts);
+	}
+
 	pbx_builtin_setvar_helper(chan, "READEXTENSTATUS", status);
 
 	return status[0] == 'H' ? -1 : 0;

Modified: team/tilghman/realtime_failover/channels/chan_local.c
URL: http://svn.digium.com/svn-view/asterisk/team/tilghman/realtime_failover/channels/chan_local.c?view=diff&rev=176703&r1=176702&r2=176703
==============================================================================
--- team/tilghman/realtime_failover/channels/chan_local.c (original)
+++ team/tilghman/realtime_failover/channels/chan_local.c Tue Feb 17 15:56:08 2009
@@ -106,8 +106,8 @@
 	char exten[AST_MAX_EXTENSION];		/* Extension to call */
 	int reqformat;				/* Requested format */
 	struct ast_jb_conf jb_conf;		/*!< jitterbuffer configuration for this local channel */
-	struct ast_channel *owner;		/* Master Channel */
-	struct ast_channel *chan;		/* Outbound channel */
+	struct ast_channel *owner;		/* Master Channel - Bridging happens here */
+	struct ast_channel *chan;		/* Outbound channel - PBX is run here */
 	struct ast_module_user *u_owner;	/*! reference to keep the module loaded while in use */
 	struct ast_module_user *u_chan;		/*! reference to keep the module loaded while in use */
 	AST_LIST_ENTRY(local_pvt) list;		/* Next entity */
@@ -303,6 +303,7 @@
 							p->chan->audiohooks = p->owner->audiohooks;
 							p->owner->audiohooks = audiohooks_swapper;
 						}
+						ast_app_group_update(p->chan, p->owner);
 						ast_channel_masquerade(p->owner, p->chan->_bridge);
 						ast_set_flag(p, LOCAL_ALREADY_MASQED);
 					}

Modified: team/tilghman/realtime_failover/channels/chan_misdn.c
URL: http://svn.digium.com/svn-view/asterisk/team/tilghman/realtime_failover/channels/chan_misdn.c?view=diff&rev=176703&r1=176702&r2=176703
==============================================================================
--- team/tilghman/realtime_failover/channels/chan_misdn.c (original)
+++ team/tilghman/realtime_failover/channels/chan_misdn.c Tue Feb 17 15:56:08 2009
@@ -379,7 +379,7 @@
 	 * \brief Tone zone sound used for dialtone generation.
 	 * \note Used as a boolean.  Non-NULL to prod generation if enabled. 
 	 */
-	const struct tone_zone_sound *ts;
+	struct ast_tone_zone_sound *ts;
 	
 	/*!
 	 * \brief Enables overlap dialing for the set amount of seconds.  (0 = Disabled)
@@ -3357,7 +3357,6 @@
 
 static int dialtone_indicate(struct chan_list *cl)
 {
-	const struct tone_zone_sound *ts = NULL;
 	struct ast_channel *ast = cl->ast;
 	int nd = 0;
 
@@ -3374,14 +3373,14 @@
 	}
 	
 	chan_misdn_log(3, cl->bc->port, " --> Dial\n");
-	ts = ast_get_indication_tone(ast->zone, "dial");
-	cl->ts = ts;	
-	
-	if (ts) {
+
+	cl->ts = ast_get_indication_tone(ast->zone, "dial");
+	
+	if (cl->ts) {
 		cl->notxtone = 0;
 		cl->norxtone = 0;
 		/* This prods us in misdn_write */
-		ast_playtones_start(ast, 0, ts->data, 0);
+		ast_playtones_start(ast, 0, cl->ts->data, 0);
 	}
 
 	return 0;
@@ -3406,8 +3405,9 @@
 	misdn_lib_tone_generator_stop(cl->bc);
 	ast_playtones_stop(ast);
 
-	cl->ts = NULL;
-	/*ast_deactivate_generator(ast);*/
+	if (cl->ts) {
+		cl->ts = ast_tone_zone_sound_unref(cl->ts);
+	}
 
 	return 0;
 }

Modified: team/tilghman/realtime_failover/channels/chan_skinny.c
URL: http://svn.digium.com/svn-view/asterisk/team/tilghman/realtime_failover/channels/chan_skinny.c?view=diff&rev=176703&r1=176702&r2=176703
==============================================================================
--- team/tilghman/realtime_failover/channels/chan_skinny.c (original)
+++ team/tilghman/realtime_failover/channels/chan_skinny.c Tue Feb 17 15:56:08 2009
@@ -3751,7 +3751,7 @@
 {
 	struct skinny_subchannel *xferor; /* the sub doing the transferring */
 	struct skinny_subchannel *xferee; /* the sub being transferred */
-	const struct tone_zone_sound *ts = NULL;
+	struct ast_tone_zone_sound *ts = NULL;
 		
 	if (ast_bridged_channel(sub->owner) || ast_bridged_channel(sub->related->owner)) {
 		if (sub->xferor) {
@@ -3774,8 +3774,10 @@
 			}
 			if (xferor->owner->_state == AST_STATE_RING) {
 				/* play ringing inband */
-				ts = ast_get_indication_tone(xferor->owner->zone, "ring");
-				ast_playtones_start(xferor->owner, 0, ts->data, 1);
+				if ((ts = ast_get_indication_tone(xferor->owner->zone, "ring"))) {
+					ast_playtones_start(xferor->owner, 0, ts->data, 1);
+					ts = ast_tone_zone_sound_unref(ts);
+				}
 			}
 			if (skinnydebug)
 				ast_debug(1, "Transfer Masquerading %s to %s\n",
@@ -3789,8 +3791,10 @@
 			ast_queue_control(xferee->owner, AST_CONTROL_UNHOLD);
 			if (xferor->owner->_state == AST_STATE_RING) {
 				/* play ringing inband */
-				ts = ast_get_indication_tone(xferor->owner->zone, "ring");
-				ast_playtones_start(xferor->owner, 0, ts->data, 1);
+				if ((ts = ast_get_indication_tone(xferor->owner->zone, "ring"))) {
+					ast_playtones_start(xferor->owner, 0, ts->data, 1);
+					ts = ast_tone_zone_sound_unref(ts);
+				}
 			}
 			if (skinnydebug)
 				ast_debug(1, "Transfer Masquerading %s to %s\n",

Modified: team/tilghman/realtime_failover/channels/chan_unistim.c
URL: http://svn.digium.com/svn-view/asterisk/team/tilghman/realtime_failover/channels/chan_unistim.c?view=diff&rev=176703&r1=176702&r2=176703
==============================================================================
--- team/tilghman/realtime_failover/channels/chan_unistim.c (original)
+++ team/tilghman/realtime_failover/channels/chan_unistim.c Tue Feb 17 15:56:08 2009
@@ -439,7 +439,7 @@
 	char datetimeformat;	    /*!< format used for displaying time/date */
 	char contrast;			  /*!< contrast */
 	char country[3];			/*!< country used for dial tone frequency */
-	struct tone_zone *tz;	       /*!< Tone zone for res_indications (ring, busy, congestion) */
+	struct ast_tone_zone *tz;	       /*!< Tone zone for res_indications (ring, busy, congestion) */
 	char ringvolume;			/*!< Ring volume */
 	char ringstyle;			 /*!< Ring melody */
 	int rtp_port;			   /*!< RTP port used by the phone */
@@ -4057,17 +4057,17 @@
 	return "UNKNOWN";
 }
 
-static void in_band_indication(struct ast_channel *ast, const struct tone_zone *tz,
+static void in_band_indication(struct ast_channel *ast, const struct ast_tone_zone *tz,
 	const char *indication)
 {
-	const struct tone_zone_sound *ts = NULL;
-
-	ts = ast_get_indication_tone(tz, indication);
-
-	if (ts && ts->data[0])
+	struct ast_tone_zone_sound *ts = NULL;
+
+	if ((ts = ast_get_indication_tone(tz, indication))) {
 		ast_playtones_start(ast, 0, ts->data, 1);
-	else
+		ts = ast_tone_zone_sound_unref(ts);
+	} else {
 		ast_log(LOG_WARNING, "Unable to get indication tone for %s\n", indication);
+	}
 }
 
 static int unistim_indicate(struct ast_channel *ast, int ind, const void *data, 
@@ -5223,6 +5223,9 @@
 		ast_log(LOG_ERROR, "An Unistim device must have at least one line!\n");
 		ast_mutex_destroy(&l->lock);
 		ast_free(l);
+		if (d->tz) {
+			d->tz = ast_tone_zone_unref(d->tz);
+		}
 		ast_free(d);
 		return NULL;
 	}
@@ -5240,6 +5243,9 @@
 			ast_log(LOG_ERROR, "You must specify the mac address with device=\n");
 			ast_mutex_destroy(&l->lock);
 			ast_free(l);
+			if (d->tz) {
+				d->tz = ast_tone_zone_unref(d->tz);
+			}
 			ast_free(d);
 			return NULL;
 		} else
@@ -5461,6 +5467,9 @@
 					d2 = d2->next;
 				}
 			}
+			if (d->tz) {
+				d->tz = ast_tone_zone_unref(d->tz);
+			}
 			ast_free(d);
 			d = devices;
 			continue;

Modified: team/tilghman/realtime_failover/configs/indications.conf.sample
URL: http://svn.digium.com/svn-view/asterisk/team/tilghman/realtime_failover/configs/indications.conf.sample?view=diff&rev=176703&r1=176702&r2=176703
==============================================================================
--- team/tilghman/realtime_failover/configs/indications.conf.sample (original)
+++ team/tilghman/realtime_failover/configs/indications.conf.sample Tue Feb 17 15:56:08 2009
@@ -1,6 +1,9 @@
+;
 ; indications.conf
+;
 ; Configuration file for location specific tone indications
-; used by the pbx_indications module.
+;
+
 ;
 ; NOTE:
 ;    When adding countries to this file, please keep them in alphabetical
@@ -9,7 +12,7 @@
 ; The [general] category is for certain global variables.
 ; All other categories are interpreted as location specific indications
 ;
-;
+
 [general]
 country=us		; default location
 
@@ -17,9 +20,6 @@
 ; [example]
 ; description = string
 ;      The full name of your country, in English.
-; alias = iso[,iso]*
-;      List of other countries 2-letter iso codes, which have the same
-;      tone indications.
 ; ringcadence = num[,num]*
 ;      List of durations the physical bell rings.
 ; dial = tonelist
@@ -55,8 +55,6 @@
 ; concisely:
 ;   element = [!]freq[+|*freq2][/duration]
 ;   tonelist = element[,element]*
-;
-; Please note that SPACES ARE NOT ALLOWED in tone lists!
 ;
 
 [at]

Modified: team/tilghman/realtime_failover/funcs/func_channel.c
URL: http://svn.digium.com/svn-view/asterisk/team/tilghman/realtime_failover/funcs/func_channel.c?view=diff&rev=176703&r1=176702&r2=176703
==============================================================================
--- team/tilghman/realtime_failover/funcs/func_channel.c (original)
+++ team/tilghman/realtime_failover/funcs/func_channel.c Tue Feb 17 15:56:08 2009
@@ -296,12 +296,19 @@
 	}
 #endif
 	else if (!strcasecmp(data, "tonezone")) {
-		struct tone_zone *new_zone;
+		struct ast_tone_zone *new_zone;
 		if (!(new_zone = ast_get_indication_zone(value))) {
 			ast_log(LOG_ERROR, "Unknown country code '%s' for tonezone. Check indications.conf for available country codes.\n", value);
 			ret = -1;	
-		} else 
-			chan->zone = new_zone;
+		} else {
+			ast_channel_lock(chan);
+			if (chan->zone) {
+				chan->zone = ast_tone_zone_unref(chan->zone);
+			}
+			chan->zone = ast_tone_zone_ref(new_zone);
+			ast_channel_unlock(chan);
+			new_zone = ast_tone_zone_unref(new_zone);
+		}
 	} else if (!strcasecmp(data, "callgroup"))
 		chan->callgroup = ast_get_group(value);
 	else if (!strcasecmp(data, "txgain")) {

Modified: team/tilghman/realtime_failover/funcs/func_odbc.c
URL: http://svn.digium.com/svn-view/asterisk/team/tilghman/realtime_failover/funcs/func_odbc.c?view=diff&rev=176703&r1=176702&r2=176703
==============================================================================
--- team/tilghman/realtime_failover/funcs/func_odbc.c (original)
+++ team/tilghman/realtime_failover/funcs/func_odbc.c Tue Feb 17 15:56:08 2009
@@ -338,8 +338,10 @@
 		SQLCloseCursor(stmt);
 		SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 	}
-	if (obj)
+	if (obj) {
 		ast_odbc_release_obj(obj);
+		obj = NULL;
+	}
 
 	if (chan)
 		ast_autoservice_stop(chan);
@@ -443,6 +445,7 @@
 		ast_log(LOG_ERROR, "Unable to execute query [%s]\n", ast_str_buffer(sql));
 		if (obj) {
 			ast_odbc_release_obj(obj);
+			obj = NULL;
 		}
 		pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
 		if (chan) {
@@ -460,6 +463,7 @@
 		SQLCloseCursor(stmt);
 		SQLFreeHandle (SQL_HANDLE_STMT, stmt);
 		ast_odbc_release_obj(obj);
+		obj = NULL;
 		pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
 		if (chan) {
 			ast_autoservice_stop(chan);
@@ -486,6 +490,7 @@
 		SQLCloseCursor(stmt);
 		SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 		ast_odbc_release_obj(obj);
+		obj = NULL;
 		pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
 		pbx_builtin_setvar_helper(chan, "ODBCSTATUS", status);
 		if (chan)
@@ -528,6 +533,7 @@
 						SQLCloseCursor(stmt);
 						SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 						ast_odbc_release_obj(obj);
+						obj = NULL;
 						pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
 						pbx_builtin_setvar_helper(chan, "ODBCSTATUS", "MEMERROR");
 						if (chan)
@@ -625,6 +631,7 @@
 			SQLCloseCursor(stmt);
 			SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 			ast_odbc_release_obj(obj);
+			obj = NULL;
 			if (chan)
 				ast_autoservice_stop(chan);
 			if (bogus_chan)
@@ -637,6 +644,7 @@
 	SQLCloseCursor(stmt);
 	SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 	ast_odbc_release_obj(obj);
+	obj = NULL;
 	if (chan)
 		ast_autoservice_stop(chan);
 	if (bogus_chan)
@@ -1056,6 +1064,7 @@
 			ast_debug(1, "Got obj\n");
 			if (!(stmt = ast_odbc_direct_execute(obj, generic_execute, ast_str_buffer(sql)))) {
 				ast_odbc_release_obj(obj);
+				obj = NULL;
 				continue;
 			}
 
@@ -1067,6 +1076,7 @@
 				SQLCloseCursor(stmt);
 				SQLFreeHandle (SQL_HANDLE_STMT, stmt);
 				ast_odbc_release_obj(obj);
+				obj = NULL;
 				AST_RWLIST_UNLOCK(&queries);
 				return CLI_SUCCESS;
 			}
@@ -1076,6 +1086,7 @@
 				SQLCloseCursor(stmt);
 				SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 				ast_odbc_release_obj(obj);
+				obj = NULL;
 				if (res == SQL_NO_DATA) {
 					ast_cli(a->fd, "Returned %d rows.  Query executed on handle %d:%s [%s]\n", rows, dsn, query->readhandle[dsn], ast_str_buffer(sql));
 					break;
@@ -1103,27 +1114,33 @@
 						SQLCloseCursor(stmt);
 						SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 						ast_odbc_release_obj(obj);
+						obj = NULL;
 						AST_RWLIST_UNLOCK(&queries);
 						return CLI_SUCCESS;
 					}
 
 					ast_cli(a->fd, "%-20.20s  %s\n", colname, ast_str_buffer(coldata));
 				}
+				rows++;
+
 				/* Get next row */
 				res = SQLFetch(stmt);
 				if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
 					break;
 				}
 				ast_cli(a->fd, "%-20.20s  %s\n", "----------", "----------");
-				rows++;
 			}
 			SQLCloseCursor(stmt);
 			SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 			ast_odbc_release_obj(obj);
-			ast_cli(a->fd, "Returned %d rows.  Query executed on handle %d [%s]\n", rows, dsn, query->readhandle[dsn]);
+			obj = NULL;
+			ast_cli(a->fd, "Returned %d row%s.  Query executed on handle %d [%s]\n", rows, rows == 1 ? "" : "s", dsn, query->readhandle[dsn]);
 			break;
 		}
-		ast_odbc_release_obj(obj);
+		if (obj) {
+			ast_odbc_release_obj(obj);
+			obj = NULL;
+		}
 
 		if (!executed) {
 			ast_cli(a->fd, "Failed to execute query. [%s]\n", ast_str_buffer(sql));
@@ -1252,6 +1269,7 @@
 			}
 			if (!(stmt = ast_odbc_direct_execute(obj, generic_execute, ast_str_buffer(sql)))) {
 				ast_odbc_release_obj(obj);
+				obj = NULL;
 				continue;
 			}
 
@@ -1259,6 +1277,7 @@
 			SQLCloseCursor(stmt);
 			SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 			ast_odbc_release_obj(obj);
+			obj = NULL;
 			ast_cli(a->fd, "Affected %d rows.  Query executed on handle %d [%s]\n", (int)rows, dsn, query->writehandle[dsn]);
 			executed = 1;
 			break;

Modified: team/tilghman/realtime_failover/include/asterisk/_private.h
URL: http://svn.digium.com/svn-view/asterisk/team/tilghman/realtime_failover/include/asterisk/_private.h?view=diff&rev=176703&r1=176702&r2=176703
==============================================================================
--- team/tilghman/realtime_failover/include/asterisk/_private.h (original)
+++ team/tilghman/realtime_failover/include/asterisk/_private.h Tue Feb 17 15:56:08 2009
@@ -39,6 +39,8 @@
 int ast_http_reload(void);		/*!< Provided by http.c */
 int ast_tps_init(void); 		/*!< Provided by taskprocessor.c */
 int ast_timing_init(void);		/*!< Provided by timing.c */
+int ast_indications_init(void); /*!< Provided by indications.c */
+int ast_indications_reload(void);/*!< Provided by indications.c */
 
 /*!
  * \brief Reload asterisk modules.

Modified: team/tilghman/realtime_failover/include/asterisk/channel.h
URL: http://svn.digium.com/svn-view/asterisk/team/tilghman/realtime_failover/include/asterisk/channel.h?view=diff&rev=176703&r1=176702&r2=176703
==============================================================================
--- team/tilghman/realtime_failover/include/asterisk/channel.h (original)
+++ team/tilghman/realtime_failover/include/asterisk/channel.h Tue Feb 17 15:56:08 2009
@@ -424,7 +424,7 @@
 	struct ast_trans_pvt *readtrans;		/*!< Read translation path */
 	struct ast_audiohook_list *audiohooks;
 	struct ast_cdr *cdr;				/*!< Call Detail Record */
-	struct tone_zone *zone;			/*!< Tone zone as set in indications.conf or
+	struct ast_tone_zone *zone;			/*!< Tone zone as set in indications.conf or
 							     in the CHANNEL dialplan function */
 	struct ast_channel_monitor *monitor;		/*!< Channel monitoring */
 #ifdef HAVE_EPOLL

Modified: team/tilghman/realtime_failover/include/asterisk/config.h
URL: http://svn.digium.com/svn-view/asterisk/team/tilghman/realtime_failover/include/asterisk/config.h?view=diff&rev=176703&r1=176702&r2=176703
==============================================================================
--- team/tilghman/realtime_failover/include/asterisk/config.h (original)
+++ team/tilghman/realtime_failover/include/asterisk/config.h Tue Feb 17 15:56:08 2009
@@ -257,10 +257,11 @@
 /*! 
  * \brief Retrieve realtime configuration 
  * \param family which family/config to lookup
+ *
  * This will use builtin configuration backends to look up a particular 
  * entity in realtime and return a variable list of its parameters. Unlike
  * the ast_load_realtime, this function can return more than one entry and
- * is thus stored inside a taditional ast_config structure rather than 
+ * is thus stored inside a traditional ast_config structure rather than 
  * just returning a linked list of variables.
  *
  * Note that you should use the constant SENTINEL to terminate arguments, in

Modified: team/tilghman/realtime_failover/include/asterisk/indications.h
URL: http://svn.digium.com/svn-view/asterisk/team/tilghman/realtime_failover/include/asterisk/indications.h?view=diff&rev=176703&r1=176702&r2=176703
==============================================================================
--- team/tilghman/realtime_failover/include/asterisk/indications.h (original)
+++ team/tilghman/realtime_failover/include/asterisk/indications.h Tue Feb 17 15:56:08 2009
@@ -1,91 +1,251 @@
 /*
  * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2002, Pauline Middelink
+ * Copyright (C) 2009, Digium, Inc.
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk project. Please do not directly contact
  * any of the maintainers of this project for assistance;
  * the project provides a web site, mailing lists and IRC
  * channels for your use.
- */
-
-/*! \file
- * \brief BSD Telephony Of Mexico "Tormenta" Tone Zone Support 2/22/01
- * 
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
- *
- * Primary Author: Pauline Middelink <middelink at polyware.nl>
- *
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \brief Tone Indication Support
+ *
+ * \author Pauline Middelink <middelink at polyware.nl>
+ * \author Russell Bryant <russell at digium.com>
  */
 
 #ifndef _ASTERISK_INDICATIONS_H
 #define _ASTERISK_INDICATIONS_H
 
-#include "asterisk/lock.h"
-
-/*! \brief Description is a series of tones of the format:
-	   [!]freq1[+freq2][/duration] separated by commas.  There
-	   are no spaces.  The sequence is repeated back to the 
-	   first tone description not preceeded by !. Duration is
-	   specified in milliseconds */
-struct tone_zone_sound {
-	const char *name;			/*!< Identifing name */
-	const char *data;			/*!< Actual zone description */
-	AST_LIST_ENTRY(tone_zone_sound) list;
+#include "asterisk/astobj2.h"
+
+/*!
+ * \brief Description of a tone
+ */
+struct ast_tone_zone_sound {
+	/*! \brief Name of the tone.  For example, "busy". */
+	const char *name;
+	/*!
+	 * \brief Description of a tone
+	 *
+	 * The format is a comma separated list of tone parts in the following format:
+	 *
+	 * Format: [!][M]freq[<+|*>freq2][/duration]
+	 *  - '!' - means that the element is NOT repeated
+	 *  - 'M' - interpret the frequencies as midi notes instead of frequencies
+	 *  - freq - The first frequency
+	 *  - freq2 - The second frequency (optional)
+	 *  - '*' - modulate freq by freq2 at a fixed depth of 90%
+	 *  - '+' - combine the frequencies
+	 *  - duration - the length of the tone part (optional, forever if not specified)
+	 */
+	const char *data;
+	/*! \brief Linked list fields for including in the list on an ast_tone_zone */
+	AST_LIST_ENTRY(ast_tone_zone_sound) entry;
+	/*! \brief Flags only used internally */
+	union {
+		uint32_t __padding;
+		struct {
+			unsigned int killme:1;
+		};
+	};
 };
 
-struct tone_zone {
-	AST_RWLIST_ENTRY(tone_zone) list;
-	char country[5];				/*!< Country code */
-	char alias[5];					/*!< is this an alias? */
-	char description[40];				/*!< Description */
-	int  nrringcadence;				/*!< # registered ringcadence elements */
-	int *ringcadence;				/*!< Ring cadence */
-	AST_LIST_HEAD_NOLOCK(, tone_zone_sound) tones;		/*!< The known tones for this zone */
+/*!
+ * \brief A set of tones for a given locale
+ *
+ * \note If a reference to this tone zone is held, then the country
+ *       is guaranteed not to change.  It is safe to read it without
+ *       locking the tone zone.  This is not the case for any other
+ *       field.
+ */
+struct ast_tone_zone {
+	/*! \brief Country code that this set of tones is for */
+	char country[5];
+	/*! 
+	 * \brief Text description of the given country.
+	 *
+	 * This is for nothing more than friendly display to a human.
+	 */
+	char description[40];
+	/*! \brief Number of ring cadence elements in the ringcadence array */
+	unsigned int  nrringcadence;
+	/*! 
+	 * \brief Array of ring cadence parts
+	 *
+	 * Each element is an amount of time in milliseconds.  The first element
+	 * is for time on, and from there it alternates between on and off.
+	 */
+	int *ringcadence;
+	/*! \brief A list of tones for this locale */
+	AST_LIST_HEAD_NOLOCK(, ast_tone_zone_sound) tones;
+	/*! \brief Flags only used internally */
+	union {
+		uint32_t __padding;
+		struct {
+			unsigned int killme:1;
+		};
+	};
 };
 
-/*! \brief set the default tone country */
-int ast_set_indication_country(const char *country);
-
-/*! \brief locate tone_zone, given the country. if country == NULL, use the default country */
-struct tone_zone *ast_get_indication_zone(const char *country);
-/*! \brief locate a tone_zone_sound, given the tone_zone. if tone_zone == NULL, use the default tone_zone */
-struct tone_zone_sound *ast_get_indication_tone(const struct tone_zone *zone, const char *indication);
-/*! \brief deallocate the passed tone zone */
-void ast_destroy_indication_zone(struct tone_zone *zone);
-
-/*! \brief add a new country, if country exists, it will be replaced. */
-int ast_register_indication_country(struct tone_zone *country);
-/*! \brief remove an existing country and all its indications, country must exist */
-int ast_unregister_indication_country(const char *country);
-/*! \brief add a new indication to a tone_zone. tone_zone must exist. if the indication already
- * exists, it will be replaced. */
-int ast_register_indication(struct tone_zone *zone, const char *indication, const char *tonelist);
-/*! \brief remove an existing tone_zone's indication. tone_zone must exist */
-int ast_unregister_indication(struct tone_zone *zone, const char *indication);
-
-/*! \brief Start a tone-list going */
-int ast_playtones_start(struct ast_channel *chan, int vol, const char* tonelist, int interruptible);
-/*! \brief Stop the tones from playing */
+/*!
+ * \brief A description of a part of a tone
+ *
+ * The elements in this structure map to the format described for the data
+ * part of the ast_tone_zone_sound struct.
+ */
+struct ast_tone_zone_part {
+	unsigned int freq1;
+	unsigned int freq2;
+	unsigned int time;
+	unsigned int modulate:1;
+	unsigned int midinote:1;
+};
+
+/*!
+ * \brief Parse a tone part
+ *
+ * \param s The part of a tone to parse.  This should be in the form described for
+ *        the data part of ast_tone_zone_sound.  '!' should be removed if present.
+ * \param tone_data An output parameter that contains the result of the parsing.
+ *
+ * \retval 0 success
+ * \retval -1 failure, and the contents of tone_data are undefined
+ */
+int ast_tone_zone_part_parse(const char *s, struct ast_tone_zone_part *tone_data);
+
+/*!
+ * \brief locate ast_tone_zone
+ *
+ * \param country country to find.  If NULL is provided, get the default.
+ *
+ * \return a reference to the specified country if found or NULL if not found
+ */
+struct ast_tone_zone *ast_get_indication_zone(const char *country);
+
+/*!
+ * \brief Locate a tone zone sound
+ *
+ * \param zone Zone to look in for a sound, if NULL, the default will be used
+ * \param indication Sound to look for, such as "busy"
+ *
+ * \return a reference to the specified sound if it exists, NULL if not
+ */
+struct ast_tone_zone_sound *ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication);
+
+/*!
+ * \brief Start playing a list of tones on a channel
+ *
+ * \param chan the channel to play tones on
+ * \param vol volume
+ * \param tonelist the list of tones to play, comma separated
+ * \param interruptible whether or not this tone can be interrupted
+ *
+ * \retval 0 success
+ * \retval non-zero failure
+ */
+int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible);
+
+/*!
+ * \brief Stop playing tones on a channel
+ *
+ * \param chan the channel to stop tones on
+ */
 void ast_playtones_stop(struct ast_channel *chan);
 
-/*! \brief support for walking through a list of indications */
-struct tone_zone *ast_walk_indications(const struct tone_zone *cur);
-
-#if 0
-extern struct tone_zone *tone_zones;
-extern ast_mutex_t tzlock;
-#endif
+/*!
+ * \brief Get the number of registered tone zones
+ *
+ * \return the total number of registered tone zones
+ */
+int ast_tone_zone_count(void);
+
+/*!
+ * \brief Get an iterator for the available tone zones
+ *
+ * Use ao2_iterator_next() to iterate the tone zones.
+ *
+ * \return an initialized iterator
+ */
+struct ao2_iterator ast_tone_zone_iterator_init(void);
+
+extern struct ast_tone_zone __fake_tone_zone;
+extern struct ast_tone_zone_sound __fake_tone_zone_sound;
+
+#define AST_CHECK_TONE_ZONE(tz) do { \
+	(void) ((tz) == (&__fake_tone_zone)); \
+} while (0)
+
+#define AST_CHECK_TONE_ZONE_SOUND(ts) do { \
+	(void) ((ts) == (&__fake_tone_zone_sound)); \
+} while (0)
+
+/*!
+ * \brief Lock an ast_tone_zone
+ */
+#define ast_tone_zone_lock(tz) ao2_lock(tz)
+
+/*!
+ * \brief Unlock an ast_tone_zone
+ */
+#define ast_tone_zone_unlock(tz) ao2_unlock(tz)
+
+/*!
+ * \brief Trylock an ast_tone_zone
+ */
+#define ast_tone_zone_trylock(tz) ao2_trylock(tz)
+
+/*!
+ * \brief Release a reference to an ast_tone_zone
+ *
+ * \return NULL
+ */
+#define ast_tone_zone_unref(tz) ({  \
+	AST_CHECK_TONE_ZONE(tz); \
+	ao2_ref(tz, -1); \
+	(NULL); \
+})
+
+/*!
+ * \brief Increase the reference count on an ast_tone_zone
+ *
+ * \return The tone zone provided as an argument
+ */
+#define ast_tone_zone_ref(tz) ({ \
+	AST_CHECK_TONE_ZONE(tz); \
+	ao2_ref(tz, +1); \
+	(tz); \
+})
+
+/*!
+ * \brief Release a reference to an ast_tone_zone_sound
+ *
+ * \return NULL
+ */
+#define ast_tone_zone_sound_unref(ts) ({ \
+	AST_CHECK_TONE_ZONE_SOUND(ts); \
+	ao2_ref(ts, -1); \
+	(NULL); \
+})
+
+/*!
+ * \brief Increase the reference count on an ast_tone_zone_sound
+ *

[... 2859 lines stripped ...]



More information about the asterisk-commits mailing list