Skip to content

Commit

Permalink
Fix deadlock on registration failure
Browse files Browse the repository at this point in the history
  • Loading branch information
ltrzesniewski committed Nov 12, 2020
1 parent 1a34bc1 commit a2cd6a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Abc.Zebus.Tests/Dispatch/DispatchQueueTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,12 @@ public void should_reset_local_dispatch_status()
task.Result.Errors.ShouldBeEmpty();
}

[Test, Timeout(5000)]
public void should_not_wait_for_all_messages_processed_when_not_started()
{
_dispatchQueue.WaitUntilAllMessagesAreProcessed();
}

private static void Throw()
{
throw new Exception("Test");
Expand Down
4 changes: 4 additions & 0 deletions src/Abc.Zebus/Dispatch/DispatchQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void Stop()
_queue.CompleteAdding();

_thread?.Join();
_thread = null;

_queue = new FlushableBlockingCollection<Entry>();
_logger.InfoFormat("{0} stopped", Name);
Expand Down Expand Up @@ -240,6 +241,9 @@ public virtual int Purge()
/// </returns>
public bool WaitUntilAllMessagesAreProcessed()
{
if (_thread is null)
return false;

bool continueWait, hasChanged = false;

do
Expand Down

0 comments on commit a2cd6a8

Please sign in to comment.