Skip to content

Commit

Permalink
Fix sync dispatcher in single feed mode by adding continuation (#3637)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukaszRozmej authored Nov 25, 2021
1 parent 43aed70 commit 29bfd3b
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,7 @@ public async Task Start(CancellationToken cancellationToken)
PeerInfo? allocatedPeer = allocation.Current;
if (allocatedPeer != null)
{
Task task = Dispatch(allocatedPeer, request, cancellationToken);
if (!Feed.IsMultiFeed)
{
if(Logger.IsDebug) Logger.Debug($"Awaiting single dispatch from {Feed.GetType().Name} with allocated {allocatedPeer}");
await task;
if(Logger.IsDebug) Logger.Debug($"Single dispatch from {Feed.GetType().Name} with allocated {allocatedPeer} has been processed");
}

#pragma warning disable 4014
task.ContinueWith(t =>
#pragma warning restore 4014
Task task = Dispatch(allocatedPeer, request, cancellationToken).ContinueWith(t =>
{
if (t.IsFaulted)
{
Expand All @@ -150,6 +140,13 @@ public async Task Start(CancellationToken cancellationToken)
Free(allocation);
}
}, cancellationToken);

if (!Feed.IsMultiFeed)
{
if(Logger.IsDebug) Logger.Debug($"Awaiting single dispatch from {Feed.GetType().Name} with allocated {allocatedPeer}");
await task;
if(Logger.IsDebug) Logger.Debug($"Single dispatch from {Feed.GetType().Name} with allocated {allocatedPeer} has been processed");
}
}
else
{
Expand Down

0 comments on commit 29bfd3b

Please sign in to comment.