Skip to content

Fix flaky test #771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ class WorkPool
readonly ConcurrentQueue<Work> _workQueue;
readonly CancellationTokenSource _tokenSource;
readonly ModelBase _model;
CancellationTokenRegistration _tokenRegistration;
readonly CancellationTokenRegistration _tokenRegistration;
volatile TaskCompletionSource<bool> _syncSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
private Task _task;

public WorkPool(ModelBase model)
{
Expand All @@ -57,7 +56,7 @@ public WorkPool(ModelBase model)

public void Start()
{
_task = Task.Run(Loop, CancellationToken.None);
Task.Run(Loop, CancellationToken.None);
}

public void Enqueue(Work work)
Expand All @@ -80,7 +79,7 @@ async Task Loop()
// Swallowing the task cancellation in case we are stopping work.
}

if (!_tokenSource.IsCancellationRequested && _workQueue.TryDequeue(out Work work))
while (_tokenSource.IsCancellationRequested == false && _workQueue.TryDequeue(out Work work))
{
await work.Execute(_model).ConfigureAwait(false);
}
Expand Down
2 changes: 2 additions & 0 deletions projects/client/RabbitMQ.Client/src/client/impl/ModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,9 @@ public void FinishClose()
public void HandleCommand(ISession session, Command cmd)
{
if (!DispatchAsynchronous(cmd))// Was asynchronous. Already processed. No need to process further.
{
_continuationQueue.Next().HandleCommand(cmd);
}
}

public MethodBase ModelRpc(MethodBase method, ContentHeaderBase header, byte[] body)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ public InboundFrame ReadFrame()
return RabbitMQ.Client.Impl.InboundFrame.ReadFrom(_reader);
}

private static readonly byte[] s_amqp = Encoding.ASCII.GetBytes("AMQP");
public void SendHeader()
{
byte[] headerBytes = new byte[8];
Expand Down