[asterisk-commits] irroot: branch irroot/distrotech-customers-1.8 r329669 - in /team/irroot/dist...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 27 07:28:26 CDT 2011


Author: irroot
Date: Wed Jul 27 07:28:19 2011
New Revision: 329669

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=329669
Log:
Merged revisions 329299,329333,329471,329527,329529,329613 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r329299 | rmudgett | 2011-07-22 17:44:58 +0200 (Fri, 22 Jul 2011) | 48 lines
  
  Deadlocks dealing with dialplan hints during reload.
  
  There are two remaining different deadlocks reported dealing with dialplan
  hints.
  
  The deadlock in ASTERISK-17666 is caused by invalid locking order in
  ast_remove_hint().  The hints container must be locked before the hint
  object.
  
  The deadlock in ASTERISK-17760 is caused by a catch-22 situation in
  handle_statechange().  The deadlock is caused by not having the conlock
  before calling the watcher callbacks.  Unfortunately, having that lock
  causes a different deadlock as reported in ASTERISK-16961.
  
  * Fixed ast_remove_hint() locking order.
  
  * Made handle_statechange() no longer call the watcher callbacks holding
  any locks that matter.
  
  * Made hint ao2 destructor do the watcher callbacks for extension
  deactivation to guarantee that they get called.
  
  * Fixed hint reference leak in ast_add_hint() if the callback container
  constructor failed.
  
  * Fixed hint reference leak in complete_core_show_hint() for every hint it
  found for CLI tab completion.
  
  * Adjusted locking in ast_merge_contexts_and_delete() for safety.
  
  * Added context_merge_lock to prevent ast_merge_contexts_and_delete() and
  handle_statechange() from interfering with each other.
  
  * Fixed ast_change_hint() not taking into account that the extension is
  used for the hash key.
  
  (closes issue ASTERISK-17666)
  Reported by: irroot
  Tested by: irroot
  JIRA SWP-3318
  
  (closes issue ASTERISK-17760)
  Reported by: Byron Clark
  Tested by: irroot
  JIRA SWP-3393
  
  Review: https://reviewboard.asterisk.org/r/1313/
........
  r329333 | rmudgett | 2011-07-22 23:10:40 +0200 (Fri, 22 Jul 2011) | 7 lines
  
  Fix memory leak in an allocation error path of handle_statechange().
  
  * Make use buffer accessor function in handle_statechange() rather than
  directly accessing the struct member.
  
  * Make use less redundant loop construct for iterating over hints.
........
  r329471 | pabelanger | 2011-07-25 21:49:40 +0200 (Mon, 25 Jul 2011) | 2 lines
  
  Decrease verbose messages to debug, to help clean up CLI.
........
  r329527 | jrose | 2011-07-26 15:25:35 +0200 (Tue, 26 Jul 2011) | 17 lines
  
  Fixes some voicemail forwarding behavior based around prepend mode.
  
  Formerly, prepend forwarding would have the user record a message with no useful prompt
  and an expectation for the user to push a button on the phone when finished recording.
  If a length of silence was detected instead, the recording would be canceled and the user
  would re-enter the voicemail forwarding menu. Subsequent time-outs in prepend recording
  would also bug out in the sense that they would write over the original message and get
  sent to the recipient regardless of whether they timed out or were accepted. This patch
  fixes this issue and adds a prompt which will be played after a timeout informing the
  user that they needed to press a button. Currently, the sound files that we have are
  somewhat inadquate for this, so after the call we simply have Allison say "Please try
  again. Then press pound." which actually relies on two separate sound files. Just one
  would be more appropriate.
  
  reporter: Vlad Povorozniuc
  Review: https://reviewboard.asterisk.org/r/1327/ 
........
  r329529 | jrose | 2011-07-26 16:04:55 +0200 (Tue, 26 Jul 2011) | 5 lines
  
  Changes sound file for prepend "then-press-pound" to "vm-then-pound" which is the same
  prompt, only it turned out "then-press-pound" was part of extra sounds. Also, vm is more
  appropriate anyway.
........
  r329613 | tilghman | 2011-07-27 06:23:46 +0200 (Wed, 27 Jul 2011) | 6 lines
  
  Duration and billsec are swapped in high resolution time.
  
  Closes ASTERISK-18024
  Patches:
  	20110726__ASTERISK-18024.diff by Tilghman Lesher (License 5003)
........

Modified:
    team/irroot/distrotech-customers-1.8/   (props changed)
    team/irroot/distrotech-customers-1.8/apps/app_voicemail.c
    team/irroot/distrotech-customers-1.8/cdr/cdr_odbc.c
    team/irroot/distrotech-customers-1.8/configs/voicemail.conf.sample
    team/irroot/distrotech-customers-1.8/include/asterisk/app.h
    team/irroot/distrotech-customers-1.8/main/app.c
    team/irroot/distrotech-customers-1.8/main/enum.c
    team/irroot/distrotech-customers-1.8/main/pbx.c

Propchange: team/irroot/distrotech-customers-1.8/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/irroot/distrotech-customers-1.8/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Jul 27 07:28:19 2011
@@ -1,1 +1,1 @@
-/branches/1.8:1-329216
+/branches/1.8:1-329668

Modified: team/irroot/distrotech-customers-1.8/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-1.8/apps/app_voicemail.c?view=diff&rev=329669&r1=329668&r2=329669
==============================================================================
--- team/irroot/distrotech-customers-1.8/apps/app_voicemail.c (original)
+++ team/irroot/distrotech-customers-1.8/apps/app_voicemail.c Wed Jul 27 07:28:19 2011
@@ -863,6 +863,18 @@
 static char vm_invalid_password[80] = "vm-invalid-password";
 static char vm_pls_try_again[80] = "vm-pls-try-again";
 
+/*
+ * XXX If we have the time, motivation, etc. to fix up this prompt, one of the following would be appropriate:
+ * 1. create a sound along the lines of "Please try again.  When done, press the pound key" which could be spliced
+ * from existing sound clips.  This would require some programming changes in the area of vm_forward options and also
+ * app.c's __ast_play_and_record function
+ * 2. create a sound prompt saying "Please try again.  When done recording, press any key to stop and send the prepended
+ * message."  At the time of this comment, I think this would require new voice work to be commissioned.
+ * 3. Something way different like providing instructions before a time out or a post-recording menu.  This would require
+ * more effort than either of the other two.
+ */
+static char vm_prepend_timeout[80] = "vm-then-pound";
+
 static struct ast_flags globalflags = {0};
 
 static int saydurationminfo;
@@ -6883,7 +6895,10 @@
 				ast_channel_setoption(chan, AST_OPTION_RXGAIN, &record_gain, sizeof(record_gain), 0);
 
 			cmd = ast_play_and_prepend(chan, NULL, msgfile, 0, vm_fmts, &prepend_duration, 1, silencethreshold, maxsilence);
-			if (cmd == 'S') {
+
+			if (cmd == 'S') { /* If we timed out, tell the user it didn't work properly and clean up the files */
+				ast_stream_and_wait(chan, vm_pls_try_again, ""); /* this might be removed if a proper vm_prepend_timeout is ever recorded */
+				ast_stream_and_wait(chan, vm_prepend_timeout, "");
 				ast_filerename(backup, msgfile, NULL);
 			}
 
@@ -6920,6 +6935,9 @@
 			cmd = '*';
 			break;
 		default: 
+			/* If time_out and return to menu, reset already_recorded */
+			already_recorded = 0;
+
 			cmd = ast_play_and_wait(chan, "vm-forwardoptions");
 				/* "Press 1 to prepend a message or 2 to forward the message without prepending" */
 			if (!cmd)
@@ -6929,8 +6947,9 @@
 				cmd = ast_waitfordigit(chan, 6000);
 			if (!cmd)
 				retries++;
-			if (retries > 3)
-				cmd = 't';
+			if (retries > 3) {
+				cmd = '*'; /* Let's cancel this beast */
+			}
 		}
 	}
 
@@ -6945,7 +6964,7 @@
 		rename(backup_textfile, textfile);
 	}
 
-	if (cmd == 't' || cmd == 'S')
+	if (cmd == 't' || cmd == 'S') /* XXX entering this block with a value of 'S' is probably no longer possible. */
 		cmd = 0;
 	return cmd;
 }
@@ -12167,6 +12186,9 @@
 		if ((val = ast_variable_retrieve(cfg, "general", "vm-pls-try-again"))) {
 			ast_copy_string(vm_pls_try_again, val, sizeof(vm_pls_try_again));
 		}
+		if ((val = ast_variable_retrieve(cfg, "general", "vm-prepend-timeout"))) {
+			ast_copy_string(vm_prepend_timeout, val, sizeof(vm_prepend_timeout));
+		}
 		/* load configurable audio prompts */
 		if ((val = ast_variable_retrieve(cfg, "general", "listen-control-forward-key")) && is_valid_dtmf(val))
 			ast_copy_string(listen_control_forward_key, val, sizeof(listen_control_forward_key));

Modified: team/irroot/distrotech-customers-1.8/cdr/cdr_odbc.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-1.8/cdr/cdr_odbc.c?view=diff&rev=329669&r1=329668&r2=329669
==============================================================================
--- team/irroot/distrotech-customers-1.8/cdr/cdr_odbc.c (original)
+++ team/irroot/distrotech-customers-1.8/cdr/cdr_odbc.c Wed Jul 27 07:28:19 2011
@@ -108,8 +108,8 @@
 		}
 		hrduration = (double) ast_tvdiff_us(cdr->end, cdr->start) / 1000000.0;
 
-		SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_FLOAT, 0, 0, &hrbillsec, 0, NULL);
-		SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_FLOAT, 0, 0, &hrduration, 0, NULL);
+		SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_FLOAT, 0, 0, &hrduration, 0, NULL);
+		SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_FLOAT, 0, 0, &hrbillsec, 0, NULL);
 	} else {
 		SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->duration, 0, NULL);
 		SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->billsec, 0, NULL);

Modified: team/irroot/distrotech-customers-1.8/configs/voicemail.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-1.8/configs/voicemail.conf.sample?view=diff&rev=329669&r1=329668&r2=329669
==============================================================================
--- team/irroot/distrotech-customers-1.8/configs/voicemail.conf.sample (original)
+++ team/irroot/distrotech-customers-1.8/configs/voicemail.conf.sample Wed Jul 27 07:28:19 2011
@@ -318,6 +318,12 @@
 ; vm-pls-try-again=custom_sound
                         ; Customize which sound file is used instead of the
                         ; default prompt that says "Please try again."
+; vm-prepend-timeout=custom_sound
+                        ; Customize which sound file is used when the user
+                        ; times out while recording a prepend message instead
+                        ; of the default prompt that says "then press pound"
+                        ; note that this will currently follow vm-pls-try-again.
+                        ; this behavior is subject to change in the near future.
 ; listen-control-forward-key=#	; Customize the key that fast-forwards message playback
 ; listen-control-reverse-key=*	; Customize the key that rewinds message playback
 ; listen-control-pause-key=0	; Customize the key that pauses/unpauses message playback

Modified: team/irroot/distrotech-customers-1.8/include/asterisk/app.h
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-1.8/include/asterisk/app.h?view=diff&rev=329669&r1=329668&r2=329669
==============================================================================
--- team/irroot/distrotech-customers-1.8/include/asterisk/app.h (original)
+++ team/irroot/distrotech-customers-1.8/include/asterisk/app.h Wed Jul 27 07:28:19 2011
@@ -270,18 +270,68 @@
 /*! \brief Play a stream and wait for a digit, returning the digit that was pressed */
 int ast_play_and_wait(struct ast_channel *chan, const char *fn);
 
+/*!
+ * \brief Record a file based on input from a channel
+ *        This function will play "auth-thankyou" upon successful recording.
+ *
+ * \param chan the channel being recorded
+ * \param playfile Filename of sound to play before recording begins
+ * \param recordfile Filename to save the recording
+ * \param maxtime_sec Longest possible message length in seconds
+ * \param fmt string containing all formats to be recorded delimited by '|'
+ * \param duration pointer to integer for storing length of the recording
+ * \param silencethreshold tolerance of noise levels that can be considered silence for the purpose of silence timeout, -1 for default
+ * \param maxsilence_ms Length of time in milliseconds which will trigger a timeout from silence, -1 for default
+ * \param path Optional filesystem path to unlock
+ * \param acceptdtmf Character of DTMF to end and accept the recording
+ * \param canceldtmf Character of DTMF to end and cancel the recording
+ *
+ * \retval -1 failure or hangup
+ * \retval 'S' Recording ended from silence timeout
+ * \retval 't' Recording ended from the message exceeding the maximum duration
+ * \retval dtmfchar Recording ended via the return value's DTMF character for either cancel or accept.
+ */
 int ast_play_and_record_full(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int silencethreshold, int maxsilence_ms, const char *path, const char *acceptdtmf, const char *canceldtmf);
 
-/*! \brief Record a file for a max amount of time (in seconds), in a given list of formats separated by '|', outputting the duration of the recording, and with a maximum
- \n
- permitted silence time in milliseconds of 'maxsilence' under 'silencethreshold' or use '-1' for either or both parameters for defaults.
-     calls ast_unlock_path() on 'path' if passed */
+/*!
+ * \brief Record a file based on input from a channel. Use default accept and cancel DTMF.
+ *        This function will play "auth-thankyou" upon successful recording.
+ *
+ * \param chan the channel being recorded
+ * \param playfile Filename of sound to play before recording begins
+ * \param recordfile Filename to save the recording
+ * \param maxtime_sec Longest possible message length in seconds
+ * \param fmt string containing all formats to be recorded delimited by '|'
+ * \param duration pointer to integer for storing length of the recording
+ * \param silencethreshold tolerance of noise levels that can be considered silence for the purpose of silence timeout, -1 for default
+ * \param maxsilence_ms length of time in milliseconds which will trigger a timeout from silence, -1 for default
+ * \param path Optional filesystem path to unlock
+ *
+ * \retval -1 failure or hangup
+ * \retval 'S' Recording ended from silence timeout
+ * \retval 't' Recording ended from the message exceeding the maximum duration
+ * \retval dtmfchar Recording ended via the return value's DTMF character for either cancel or accept.
+ */
 int ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int silencethreshold, int maxsilence_ms, const char *path);
 
-/*! \brief Record a message and prepend the message to the given record file after
-    playing the optional playfile (or a beep), storing the duration in
-    'duration' and with a maximum permitted silence time in milliseconds of 'maxsilence' under
-    'silencethreshold' or use '-1' for either or both parameters for defaults. */
+/*!
+ * \brief Record a file based on input frm a channel. Recording is performed in 'prepend' mode which works a little differently from normal recordings
+ *        This function will not play a success message due to post-recording control in the application this was added for.
+ *
+ * \param chan the channel being recorded
+ * \param playfile Filename of sound to play before recording begins
+ * \param recordfile Filename to save the recording
+ * \param maxtime_sec Longest possible message length in seconds
+ * \param fmt string containing all formats to be recorded delimited by '|'
+ * \param duration pointer to integer for storing length of the recording
+ * \param beep whether to play a beep to prompt the recording
+ * \param silencethreshold tolerance of noise levels that can be considered silence for the purpose of silence timeout, -1 for default
+ * \param maxsilence_ms length of time in milliseconds which will trigger a timeout from silence, -1 for default.
+ *
+ * \retval -1 failure or hangup
+ * \retval 'S' Recording ended from silence timeout
+ * \retval 't' Recording either exceeded maximum duration or the call was ended via DTMF
+ */
 int ast_play_and_prepend(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime_sec, char *fmt, int *duration, int beep, int silencethreshold, int maxsilence_ms);
 
 enum ast_getdata_result {

Modified: team/irroot/distrotech-customers-1.8/main/app.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-1.8/main/app.c?view=diff&rev=329669&r1=329668&r2=329669
==============================================================================
--- team/irroot/distrotech-customers-1.8/main/app.c (original)
+++ team/irroot/distrotech-customers-1.8/main/app.c Wed Jul 27 07:28:19 2011
@@ -715,19 +715,24 @@
  * \param chan Channel to playback to/record from.
  * \param playfile Filename of sound to play before recording begins.
  * \param recordfile Filename to record to.
- * \param maxtime Maximum length of recording (in milliseconds).
+ * \param maxtime Maximum length of recording (in seconds).
  * \param fmt Format(s) to record message in. Multiple formats may be specified by separating them with a '|'.
  * \param duration Where to store actual length of the recorded message (in milliseconds).
  * \param beep Whether to play a beep before starting to record.
  * \param silencethreshold
  * \param maxsilence Length of silence that will end a recording (in milliseconds).
  * \param path Optional filesystem path to unlock.
- * \param prepend If true, prepend the recorded audio to an existing file.
+ * \param prepend If true, prepend the recorded audio to an existing file and follow prepend mode recording rules
  * \param acceptdtmf DTMF digits that will end the recording.
  * \param canceldtmf DTMF digits that will cancel the recording.
+ * \param skip_confirmation_sound If true, don't play auth-thankyou at end. Nice for custom recording prompts in apps.
+ *
+ * \retval -1 failure or hangup
+ * \retval 'S' Recording ended from silence timeout
+ * \retval 't' Recording ended from the message exceeding the maximum duration, or via DTMF in prepend mode
+ * \retval dtmfchar Recording ended via the return value's DTMF character for either cancel or accept.
  */
-
-static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int beep, int silencethreshold, int maxsilence, const char *path, int prepend, const char *acceptdtmf, const char *canceldtmf)
+static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int beep, int silencethreshold, int maxsilence, const char *path, int prepend, const char *acceptdtmf, const char *canceldtmf, int skip_confirmation_sound)
 {
 	int d = 0;
 	char *fmts;
@@ -1007,7 +1012,7 @@
 	if (rfmt && ast_set_read_format(chan, rfmt)) {
 		ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(rfmt), chan->name);
 	}
-	if (outmsg == 2) {
+	if ((outmsg == 2) && (!skip_confirmation_sound)) {
 		ast_stream_and_wait(chan, "auth-thankyou", "");
 	}
 	if (sildet) {
@@ -1021,17 +1026,17 @@
 
 int ast_play_and_record_full(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int silencethreshold, int maxsilence, const char *path, const char *acceptdtmf, const char *canceldtmf)
 {
-	return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, 0, silencethreshold, maxsilence, path, 0, S_OR(acceptdtmf, default_acceptdtmf), S_OR(canceldtmf, default_canceldtmf));
+	return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, 0, silencethreshold, maxsilence, path, 0, S_OR(acceptdtmf, default_acceptdtmf), S_OR(canceldtmf, default_canceldtmf), 0);
 }
 
 int ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int silencethreshold, int maxsilence, const char *path)
 {
-	return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, 0, silencethreshold, maxsilence, path, 0, default_acceptdtmf, default_canceldtmf);
+	return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, 0, silencethreshold, maxsilence, path, 0, default_acceptdtmf, default_canceldtmf, 0);
 }
 
 int ast_play_and_prepend(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt, int *duration, int beep, int silencethreshold, int maxsilence)
 {
-	return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, beep, silencethreshold, maxsilence, NULL, 1, default_acceptdtmf, default_canceldtmf);
+	return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, beep, silencethreshold, maxsilence, NULL, 1, default_acceptdtmf, default_canceldtmf, 1);
 }
 
 /* Channel group core functions */

Modified: team/irroot/distrotech-customers-1.8/main/enum.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-1.8/main/enum.c?view=diff&rev=329669&r1=329668&r2=329669
==============================================================================
--- team/irroot/distrotech-customers-1.8/main/enum.c (original)
+++ team/irroot/distrotech-customers-1.8/main/enum.c Wed Jul 27 07:28:19 2011
@@ -644,13 +644,13 @@
 	int z = 0;
 	int spaceleft = 0;
 	struct timeval time_start, time_end;
- 
+
 	if (ast_strlen_zero(suffix)) {
 		ast_log(LOG_WARNING, "ast_get_enum need a suffix parameter now.\n");
 		return -1;
 	}
 
-	ast_verb(2, "ast_get_enum(num='%s', tech='%s', suffix='%s', options='%s', record=%d\n", number, tech, suffix, options, record);
+	ast_debug(2, "num='%s', tech='%s', suffix='%s', options='%s', record=%d\n", number, tech, suffix, options, record);
 
 /*
   We don't need that any more, that "n" preceding the number has been replaced by a flag
@@ -668,11 +668,12 @@
 		number++;
 	}
 
-	if (!(context = ast_calloc(1, sizeof(*context))))
-		return -1;
-
-	if((p3 = strchr(naptrinput, '*'))) {
-		*p3='\0';		
+	if (!(context = ast_calloc(1, sizeof(*context)))) {
+		return -1;
+	}
+
+	if ((p3 = strchr(naptrinput, '*'))) {
+		*p3='\0';
 	}
 
 	context->naptrinput = naptrinput;	/* The number */
@@ -710,8 +711,8 @@
 			context->options |= ENUMLOOKUP_OPTIONS_ISN;
 		}
 	}
-	ast_verb(2, "ENUM options(%s): pos=%d, options='%d'\n", options, context->position, context->options);
-	ast_debug(1, "ast_get_enum(): n='%s', tech='%s', suffix='%s', options='%d', record='%d'\n",
+	ast_debug(2, "ENUM options(%s): pos=%d, options='%d'\n", options, context->position, context->options);
+	ast_debug(1, "n='%s', tech='%s', suffix='%s', options='%d', record='%d'\n",
 			number, tech, suffix, context->options, context->position);
 
 	/*
@@ -742,15 +743,13 @@
 		ast_copy_string(left, number, sizeof(left));
 		ast_copy_string(middle, p1, sizeof(middle) - 1);
 		strcat(middle, ".");
-
-		ast_verb(2, "ISN ENUM: left=%s, middle='%s'\n", left, middle);
+		ast_debug(2, "ISN ENUM: left=%s, middle='%s'\n", left, middle);
 	/* Direct DNS lookup rewrite */
 	} else if (context->options & ENUMLOOKUP_OPTIONS_DIRECT) {
 		left[0] = 0; /* nothing to flip around */
 		ast_copy_string(middle, number, sizeof(middle) - 1);
 		strcat(middle, ".");
- 
-		ast_verb(2, "DIRECT ENUM:  middle='%s'\n", middle);
+		ast_debug(2, "DIRECT ENUM:  middle='%s'\n", middle);
 	/* Infrastructure ENUM rewrite */
 	} else if (context->options & ENUMLOOKUP_OPTIONS_IENUM) {
 		int sdl = 0;
@@ -769,7 +768,7 @@
 
 			if (sdl >= 0) {
 				ast_copy_string(apex, n_apex, sizeof(apex));
-				ast_verb(2, "EBL ENUM: sep=%s, apex='%s'\n", sep, n_apex);
+				ast_debug(2, "EBL ENUM: sep=%s, apex='%s'\n", sep, n_apex);
 			} else {
 				sdl = cc_len;
 			}
@@ -778,8 +777,9 @@
 			ast_copy_string(cc, number, cc_len); /* cclen() never returns more than 3 */
 			sdl = blr_txt(cc, suffix);
 
-			if (sdl < 0) 
+			if (sdl < 0) {
 				sdl = cc_len;
+			}
 			break;
 
 		case ENUMLOOKUP_BLR_CC:	/* BLR is at the country-code level */
@@ -814,7 +814,7 @@
 		}
 		*p1 = '\0';
 
-		ast_verb(2, "I-ENUM: cclen=%d, left=%s, middle='%s', apex='%s'\n", cc_len, left, middle, apex);
+		ast_debug(2, "I-ENUM: cclen=%d, left=%s, middle='%s', apex='%s'\n", cc_len, left, middle, apex);
 	}
 
 	if (strlen(left) * 2 + 2 > sizeof(domain)) {
@@ -851,7 +851,7 @@
 	ret = ast_search_dns(context, tmp, C_IN, T_NAPTR, enum_callback);
 	time_end = ast_tvnow();
 
-	ast_verb(2, "ast_get_enum() profiling: %s, %s, %" PRIi64 " ms\n", 
+	ast_debug(2, "profiling: %s, %s, %" PRIi64 " ms\n",
 			(ret == 0) ? "OK" : "FAIL", tmp, ast_tvdiff_ms(time_end, time_start));
 
 	if (ret < 0) {
@@ -896,11 +896,12 @@
 	} else if (!(context->options & ENUMLOOKUP_OPTIONS_COUNT)) {
 		context->dst[0] = 0;
 	} else if ((context->options & ENUMLOOKUP_OPTIONS_COUNT)) {
-		snprintf(context->dst,context->dstlen,"%d",context->count);
-	}
-
-	if (chan)
+		snprintf(context->dst, context->dstlen, "%d", context->count);
+	}
+
+	if (chan) {
 		ret |= ast_autoservice_stop(chan);
+	}
 
 	if (!argcontext) {
 		for (k = 0; k < context->naptr_rrs_count; k++) {
@@ -909,8 +910,9 @@
 		}
 		ast_free(context->naptr_rrs);
 		ast_free(context);
-	} else
+	} else {
 		*argcontext = context;
+	}
 
 	return ret;
 }

Modified: team/irroot/distrotech-customers-1.8/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-1.8/main/pbx.c?view=diff&rev=329669&r1=329668&r2=329669
==============================================================================
--- team/irroot/distrotech-customers-1.8/main/pbx.c (original)
+++ team/irroot/distrotech-customers-1.8/main/pbx.c Wed Jul 27 07:28:19 2011
@@ -4280,12 +4280,13 @@
 
 	hint_app = ast_str_create(1024);
 	if (!hint_app) {
+		ast_free(sc);
 		return -1;
 	}
 
 	ast_mutex_lock(&context_merge_lock);/* Hold off ast_merge_contexts_and_delete */
 	i = ao2_iterator_init(hints, 0);
-	for (hint = ao2_iterator_next(&i); hint; ao2_ref(hint, -1), hint = ao2_iterator_next(&i)) {
+	for (; (hint = ao2_iterator_next(&i)); ao2_ref(hint, -1)) {
 		struct ast_state_cb *state_cb;
 		char *cur, *parse;
 		int state;
@@ -4299,7 +4300,7 @@
 
 		/* Does this hint monitor the device that changed state? */
 		ast_str_set(&hint_app, 0, "%s", ast_get_extension_app(hint->exten));
-		parse = hint_app->str;
+		parse = ast_str_buffer(hint_app);
 		while ((cur = strsep(&parse, "&"))) {
 			if (!strcasecmp(cur, sc->dev)) {
 				/* The hint monitors the device. */
@@ -4321,7 +4322,6 @@
 			sizeof(context_name));
 		ast_copy_string(exten_name, ast_get_extension_name(hint->exten),
 			sizeof(exten_name));
-
 		ast_str_set(&hint_app, 0, "%s", ast_get_extension_app(hint->exten));
 		ao2_unlock(hint);
 
@@ -4341,15 +4341,26 @@
 		hint->laststate = state;	/* record we saw the change */
 
 		/* For general callbacks */
+		ao2_lock(statecbs);
 		cb_iter = ao2_iterator_init(statecbs, 0);
-		for (state_cb = ao2_iterator_next(&cb_iter); state_cb; ao2_ref(state_cb, -1), state_cb = ao2_iterator_next(&cb_iter)) {
-			state_cb->callback(context_name, exten_name, state, state_cb->data);
-		}
+		for (; (state_cb = ao2_iterator_next(&cb_iter)); ao2_ref(state_cb, -1)) {
+			void *data;
+
+			/*
+			 * Protect the data ptr because it could get updated by
+			 * ast_extension_state_add().
+			 */
+			data = state_cb->data;
+			ao2_unlock(statecbs);
+			state_cb->callback(context_name, exten_name, state, data);
+			ao2_lock(statecbs);
+		}
+		ao2_unlock(statecbs);
 		ao2_iterator_destroy(&cb_iter);
 
 		/* For extension callbacks */
 		cb_iter = ao2_iterator_init(hint->callbacks, 0);
-		for (state_cb = ao2_iterator_next(&cb_iter); state_cb; ao2_ref(state_cb, -1), state_cb = ao2_iterator_next(&cb_iter)) {
+		for (; (state_cb = ao2_iterator_next(&cb_iter)); ao2_ref(state_cb, -1)) {
 			state_cb->callback(context_name, exten_name, state, state_cb->data);
 		}
 		ao2_iterator_destroy(&cb_iter);
@@ -4609,7 +4620,7 @@
 	/* Prevent multiple add hints from adding the same hint at the same time. */
 	ao2_lock(hints);
 
-	/* Search if hint exists, do nothing */	
+	/* Search if hint exists, do nothing */
 	hint_found = ao2_find(hints, e, 0);
 	if (hint_found) {
 		ao2_ref(hint_found, -1);
@@ -5906,7 +5917,7 @@
 	ast_cli(a->fd, "\n    -= Registered Asterisk Dial Plan Hints =-\n");
 
 	i = ao2_iterator_init(hints, 0);
-	for (hint = ao2_iterator_next(&i); hint; ao2_ref(hint, -1), hint = ao2_iterator_next(&i)) {
+	for (; (hint = ao2_iterator_next(&i)); ao2_ref(hint, -1)) {
 		ao2_lock(hint);
 		if (!hint->exten) {
 			/* The extension has already been destroyed */
@@ -5945,7 +5956,7 @@
 
 	/* walk through all hints */
 	i = ao2_iterator_init(hints, 0);
-	for (hint = ao2_iterator_next(&i); hint; ao2_ref(hint, -1), hint = ao2_iterator_next(&i)) {
+	for (; (hint = ao2_iterator_next(&i)); ao2_ref(hint, -1)) {
 		ao2_lock(hint);
 		if (!hint->exten) {
 			/* The extension has already been destroyed */
@@ -5994,7 +6005,7 @@
 	
 	extenlen = strlen(a->argv[3]);
 	i = ao2_iterator_init(hints, 0);
-	for (hint = ao2_iterator_next(&i); hint; ao2_ref(hint, -1), hint = ao2_iterator_next(&i)) {
+	for (; (hint = ao2_iterator_next(&i)); ao2_ref(hint, -1)) {
 		ao2_lock(hint);
 		if (!hint->exten) {
 			/* The extension has already been destroyed */
@@ -7236,7 +7247,7 @@
 
 	/* preserve all watchers for hints */
 	i = ao2_iterator_init(hints, AO2_ITERATOR_DONTLOCK);
-	for (hint = ao2_iterator_next(&i); hint; ao2_ref(hint, -1), hint = ao2_iterator_next(&i)) {
+	for (; (hint = ao2_iterator_next(&i)); ao2_ref(hint, -1)) {
 		if (ao2_container_count(hint->callbacks)) {
 			ao2_lock(hint);
 			if (!hint->exten) {
@@ -7303,7 +7314,8 @@
 		}
 
 		/* Find the hint in the hints container */
-		if (!exten || !(hint = ao2_find(hints, exten, 0))) {
+		hint = exten ? ao2_find(hints, exten, 0) : NULL;
+		if (!hint) {
 			/* this hint has been removed, notify the watchers */
 			while ((thiscb = AST_LIST_REMOVE_HEAD(&saved_hint->callbacks, entry))) {
 				thiscb->callback(saved_hint->context, saved_hint->exten,
@@ -10028,7 +10040,7 @@
 	}
 
 	i = ao2_iterator_init(hints, 0);
-	for (hint = ao2_iterator_next(&i); hint; ao2_ref(hint, -1), hint = ao2_iterator_next(&i)) {
+	for (; (hint = ao2_iterator_next(&i)); ao2_ref(hint, -1)) {
 		watchers = ao2_container_count(hint->callbacks);
 		data_hint = ast_data_add_node(data_root, "hint");
 		if (!data_hint) {




More information about the asterisk-commits mailing list