Skip to content

Commit

Permalink
Fix possible deadlock inside MSBuild task (#3307)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoRossignoli authored and Evangelink committed Aug 2, 2024
1 parent c68d90f commit 76c9e7d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ protected override void LogEventsFromTextOutput(string singleLine, MessageImport
}

protected override void ProcessStarted()
=> _connectionLoopTask = Task.Run(() =>
=> _connectionLoopTask = Task.Run(async () =>
{
try
{
Expand All @@ -249,7 +249,7 @@ protected override void ProcessStarted()
pipeServer.RegisterSerializer(new VoidResponseSerializer(), typeof(VoidResponse));
pipeServer.RegisterSerializer(new FailedTestInfoRequestSerializer(), typeof(FailedTestInfoRequest));
pipeServer.RegisterSerializer(new RunSummaryInfoRequestSerializer(), typeof(RunSummaryInfoRequest));
pipeServer.WaitConnectionAsync(_waitForConnections.Token).GetAwaiter().GetResult();
await pipeServer.WaitConnectionAsync(_waitForConnections.Token);
_connections.Add(pipeServer);
Log.LogMessage(MessageImportance.Low, $"Client connected to '{_pipeNameDescription.Name}'");
}
Expand All @@ -258,6 +258,10 @@ protected override void ProcessStarted()
{
// Do nothing we're cancelling
}
catch (Exception ex)
{
Log.LogError(ex.ToString());
}
});

public override bool Execute()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public NamedPipeServer(
CancellationToken cancellationToken)
{
ArgumentGuard.IsNotNull(pipeNameDescription);
_namedPipeServerStream = new((PipeName = pipeNameDescription).Name, PipeDirection.InOut, maxNumberOfServerInstances);
_namedPipeServerStream = new((PipeName = pipeNameDescription).Name, PipeDirection.InOut, maxNumberOfServerInstances, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
_callback = callback;
_environment = environment;
_logger = logger;
Expand Down

0 comments on commit 76c9e7d

Please sign in to comment.