[asterisk-commits] dvossel: trunk r238635 - in /trunk: include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jan 8 13:39:35 CST 2010


Author: dvossel
Date: Fri Jan  8 13:39:30 2010
New Revision: 238635

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=238635
Log:
fixes AUDIOHOOK_INHERIT regression

During the process of removing an audiohook from one channel
and attaching it to another the audiohook's status is updated
to DONE and then back to whatever it was previously.  Typically
updating the status after setting it to DONE is not a good idea
because DONE can trigger unrecoverable audiohook destruction
events... because of this a conditional check was added to
audiohook_update_status to explicitly prevent the audiohook
from ever changing after being set to DONE.  It was this check
that prevented audiohook inherit from work properly though.

Now ast_audiohook_move_by_source is treated as a special exception,
as the audiohook must be returned to its previous status after
attaching it to the new channel.  This is only a safe operation
because the audiohook's lock is held the entire time, otherwise
this could cause trouble.

(closes issue #16522)
Reported by: corruptor


Modified:
    trunk/include/asterisk/audiohook.h
    trunk/main/audiohook.c

Modified: trunk/include/asterisk/audiohook.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/audiohook.h?view=diff&rev=238635&r1=238634&r2=238635
==============================================================================
--- trunk/include/asterisk/audiohook.h (original)
+++ trunk/include/asterisk/audiohook.h Fri Jan  8 13:39:30 2010
@@ -205,6 +205,9 @@
 /*! \brief Update audiohook's status
  * \param audiohook Audiohook structure
  * \param audiohook status enum
+ *
+ * \note once status is updated to DONE, this function can not be used to set the
+ * status back to any other setting.  Setting DONE effectively locks the status as such.
  */
 void ast_audiohook_update_status(struct ast_audiohook *audiohook, enum ast_audiohook_status status);
 

Modified: trunk/main/audiohook.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/audiohook.c?view=diff&rev=238635&r1=238634&r2=238635
==============================================================================
--- trunk/main/audiohook.c (original)
+++ trunk/main/audiohook.c Fri Jan  8 13:39:30 2010
@@ -361,7 +361,11 @@
 /*! \brief Update audiohook's status
  * \param audiohook status enum
  * \param audiohook Audiohook structure
- */
+ *
+ * \note once status is updated to DONE, this function can not be used to set the
+ * status back to any other setting.  Setting DONE effectively locks the status as such.
+ */
+
 void ast_audiohook_update_status(struct ast_audiohook *audiohook, enum ast_audiohook_status status)
 {
 	ast_audiohook_lock(audiohook);
@@ -458,6 +462,7 @@
 void ast_audiohook_move_by_source(struct ast_channel *old_chan, struct ast_channel *new_chan, const char *source)
 {
 	struct ast_audiohook *audiohook;
+	enum ast_audiohook_status oldstatus;
 
 	if (!old_chan->audiohooks || !(audiohook = find_audiohook_by_source(old_chan->audiohooks, source))) {
 		return;
@@ -466,11 +471,15 @@
 	/* By locking both channels and the audiohook, we can assure that
 	 * another thread will not have a chance to read the audiohook's status
 	 * as done, even though ast_audiohook_remove signals the trigger
-	 * condition
+	 * condition.
 	 */
 	ast_audiohook_lock(audiohook);
+	oldstatus = audiohook->status;
+
 	ast_audiohook_remove(old_chan, audiohook);
 	ast_audiohook_attach(new_chan, audiohook);
+
+	audiohook->status = oldstatus;
 	ast_audiohook_unlock(audiohook);
 }
 




More information about the asterisk-commits mailing list