[Asterisk-code-review] Revert "Add API for channel frame deferral." (asterisk[14])

George Joseph asteriskteam at digium.com
Thu Nov 10 07:38:19 CST 2016


Hello Mark Michelson, Anonymous Coward #1000019, Joshua Colp,

I'd like you to do a code review.  Please visit

    https://gerrit.asterisk.org/4372

to review the following change.


Change subject: Revert "Add API for channel frame deferral."
......................................................................

Revert "Add API for channel frame deferral."

This reverts commit 4a8b1940b896f7e783a5429d0fffee8bed0e4afd.
Multiple testsuite failures were detected after the fact.

Change-Id: Ife9f86872d323adb9c068d2942339c7be9499257
---
M include/asterisk/channel.h
M main/channel.c
M main/channel_internal_api.c
3 files changed, 0 insertions(+), 89 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/72/4372/1

diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index cf8c544..78db878 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -967,11 +967,6 @@
 	 * The channel is executing a subroutine or macro
 	 */
 	AST_FLAG_SUBROUTINE_EXEC = (1 << 27),
-	/*!
-	 * The channel is currently in an operation where
-	 * frames should be deferred.
-	 */
-	AST_FLAG_DEFER_FRAMES = (1 << 28),
 };
 
 /*! \brief ast_bridge_config flags */
@@ -4665,38 +4660,5 @@
  * \brief Get error code for latest channel operation.
  */
 enum ast_channel_error ast_channel_errno(void);
-
-/*!
- * \brief Retrieve the deferred read queue.
- */
-struct ast_readq_list *ast_channel_deferred_readq(struct ast_channel *chan);
-
-/*!
- * \brief Start deferring deferrable frames on this channel
- *
- * Sometimes, a channel gets entered into a mode where a "main" application
- * is tasked with servicing frames on the channel, but that application does
- * not need to act on those frames. However, it would be imprudent to simply
- * drop important frames. This function can be called so that important frames
- * will be deferred, rather than placed in the channel frame queue as normal.
- *
- * \pre chan MUST be locked before calling
- *
- * \param chan The channel on which frames should be deferred
- */
-void ast_channel_start_defer_frames(struct ast_channel *chan);
-
-/*!
- * \brief Stop deferring deferrable frames on this channel
- *
- * When it is time to stop deferring frames on the channel, all deferred frames
- * will be queued onto the channel's read queue so that the next servicer of
- * the channel can handle those frames as necessary.
- *
- * \pre chan MUST be locked before calling
- *
- * \param chan The channel on which to stop deferring frames.
- */
-void ast_channel_stop_defer_frames(struct ast_channel *chan);
 
 #endif /* _ASTERISK_CHANNEL_H */
diff --git a/main/channel.c b/main/channel.c
index f00f222..6e24ee6 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -1064,25 +1064,6 @@
 	return tmp;
 }
 
-void ast_channel_start_defer_frames(struct ast_channel *chan)
-{
-	ast_set_flag(ast_channel_flags(chan), AST_FLAG_DEFER_FRAMES);
-}
-
-void ast_channel_stop_defer_frames(struct ast_channel *chan)
-{
-	ast_clear_flag(ast_channel_flags(chan), AST_FLAG_DEFER_FRAMES);
-
-	/* Move the deferred frames onto the channel read queue, ahead of other queued frames */
-	ast_queue_frame_head(chan, AST_LIST_FIRST(ast_channel_deferred_readq(chan)));
-	/* ast_frfree will mosey down the list and free them all */
-	if (!AST_LIST_EMPTY(ast_channel_deferred_readq(chan))) {
-		ast_frfree(AST_LIST_FIRST(ast_channel_deferred_readq(chan)));
-	}
-	/* Reset the list to be empty */
-	AST_LIST_HEAD_INIT_NOLOCK(ast_channel_deferred_readq(chan));
-}
-
 static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int head, struct ast_frame *after)
 {
 	struct ast_frame *f;
@@ -3903,32 +3884,6 @@
 	/* Check for pending read queue */
 	if (!AST_LIST_EMPTY(ast_channel_readq(chan))) {
 		int skip_dtmf = should_skip_dtmf(chan);
-
-		if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_DEFER_FRAMES)) {
-			AST_LIST_TRAVERSE_SAFE_BEGIN(ast_channel_readq(chan), f, frame_list) {
-				if (ast_is_deferrable_frame(f)) {
-					if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_HANGUP) {
-						struct ast_frame *dup;
-
-						/* Hangup is a special case. We want to defer the frame, but we also do not
-						 * want to remove it from the frame queue. So rather than just moving the frame
-						 * over, we duplicate it and move the copy to the deferred readq.
-						 *
-						 * The reason for this? This way, whoever calls ast_read() will get a NULL return
-						 * immediately and can tell the channel has hung up and do what it needs to. Also,
-						 * when frame deferral finishes, then whoever calls ast_read() next will also get
-						 * the hangup.
-						 */
-						dup = ast_frdup(f);
-						AST_LIST_INSERT_TAIL(ast_channel_deferred_readq(chan), dup, frame_list);
-					} else {
-						AST_LIST_INSERT_TAIL(ast_channel_deferred_readq(chan), f, frame_list);
-						AST_LIST_REMOVE_CURRENT(frame_list);
-					}
-				}
-			}
-			AST_LIST_TRAVERSE_SAFE_END;
-		}
 
 		AST_LIST_TRAVERSE_SAFE_BEGIN(ast_channel_readq(chan), f, frame_list) {
 			/* We have to be picky about which frame we pull off of the readq because
diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c
index a30c605..3c156d4 100644
--- a/main/channel_internal_api.c
+++ b/main/channel_internal_api.c
@@ -223,7 +223,6 @@
 	struct stasis_cp_single *topics;		/*!< Topic for all channel's events */
 	struct stasis_forward *endpoint_forward;	/*!< Subscription for event forwarding to endpoint's topic */
 	struct stasis_forward *endpoint_cache_forward; /*!< Subscription for cache updates to endpoint's topic */
-	struct ast_readq_list deferred_readq;
 };
 
 /*! \brief The monotonically increasing integer counter for channel uniqueids */
@@ -1683,9 +1682,4 @@
 	}
 
 	return *error_code;
-}
-
-struct ast_readq_list *ast_channel_deferred_readq(struct ast_channel *chan)
-{
-	return &chan->deferred_readq;
 }

-- 
To view, visit https://gerrit.asterisk.org/4372
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ife9f86872d323adb9c068d2942339c7be9499257
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-code-review mailing list