[Asterisk-code-review] Revert "channel: Use frame deferral API for safe sleep." (asterisk[14])

George Joseph asteriskteam at digium.com
Thu Nov 10 07:37: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/4369

to review the following change.


Change subject: Revert "channel: Use frame deferral API for safe sleep."
......................................................................

Revert "channel: Use frame deferral API for safe sleep."

This reverts commit 1db9e7886cc72355663123e906cf5f2dc4a2ef84.
Multiple testsuite failures were detected after the fact.

Change-Id: Ifd5817e90371e05c4011d5cc97da145c196d60fe
---
M main/channel.c
1 file changed, 27 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/69/4369/1

diff --git a/main/channel.c b/main/channel.c
index 0d13be1..9ac8a64 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -1546,18 +1546,19 @@
 	int res = 0;
 	struct timeval start;
 	int ms;
+	AST_LIST_HEAD_NOLOCK(, ast_frame) deferred_frames;
+
+	AST_LIST_HEAD_INIT_NOLOCK(&deferred_frames);
 
 	/* If no other generator is present, start silencegen while waiting */
 	if (ast_opt_transmit_silence && !ast_channel_generatordata(chan)) {
 		silgen = ast_channel_start_silence_generator(chan);
 	}
 
-	ast_channel_lock(chan);
-	ast_channel_start_defer_frames(chan);
-	ast_channel_unlock(chan);
-
 	start = ast_tvnow();
 	while ((ms = ast_remaining_ms(start, timeout_ms))) {
+		struct ast_frame *dup_f = NULL;
+
 		if (cond && ((*cond)(data) == 0)) {
 			break;
 		}
@@ -1572,7 +1573,18 @@
 				res = -1;
 				break;
 			}
-			ast_frfree(f);
+
+			if (!ast_is_deferrable_frame(f)) {
+				ast_frfree(f);
+				continue;
+			}
+
+			if ((dup_f = ast_frisolate(f))) {
+				if (dup_f != f) {
+					ast_frfree(f);
+				}
+				AST_LIST_INSERT_HEAD(&deferred_frames, dup_f, frame_list);
+			}
 		}
 	}
 
@@ -1581,8 +1593,17 @@
 		ast_channel_stop_silence_generator(chan, silgen);
 	}
 
+	/* We need to free all the deferred frames, but we only need to
+	 * queue the deferred frames if there was no error and no
+	 * hangup was received
+	 */
 	ast_channel_lock(chan);
-	ast_channel_stop_defer_frames(chan);
+	while ((f = AST_LIST_REMOVE_HEAD(&deferred_frames, frame_list))) {
+		if (!res) {
+			ast_queue_frame_head(chan, f);
+		}
+		ast_frfree(f);
+	}
 	ast_channel_unlock(chan);
 
 	return res;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifd5817e90371e05c4011d5cc97da145c196d60fe
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