Skip to content

Commit

Permalink
Fix for a race condition while getting the log buffer (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
daveaglick committed Jun 23, 2020
1 parent 08ab99b commit d6ce605
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 1.1.3

- [Fix] Fixed a race condition when fetching a log buffer (#1, thanks @duncanawoods)

# 1.1.2

- [Fix] No longer catches certain error exceptions that actually indicate a problem
Expand Down
19 changes: 18 additions & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,23 @@ Task("Pack")
}
});

Task("Sign")
.IsDependentOn("Pack")
.WithCriteria(() => isLocal)
.Does(() =>
{
var certPass = EnvironmentVariable("DAVIDGLICK_CERTPASS");
if (string.IsNullOrEmpty(certPass))
{
throw new InvalidOperationException("Could not resolve certificate password.");
}

foreach (var nupkg in GetFiles($"{ buildDir }/*.nupkg"))
{
StartProcess("nuget", "sign \"" + nupkg.ToString() + "\" -CertificatePath \"davidglick.pfx\" -CertificatePassword \"" + certPass + "\" -Timestamper \"http://timestamp.digicert.com\" -NonInteractive");
}
});

Task("Zip")
.Description("Zips the build output.")
.IsDependentOn("Build")
Expand Down Expand Up @@ -186,7 +203,7 @@ Task("MyGet")

Task("NuGet")
.Description("Pushes the packages to the NuGet gallery.")
.IsDependentOn("Pack")
.IsDependentOn("Sign")
.WithCriteria(() => isLocal)
.Does(() =>
{
Expand Down
17 changes: 15 additions & 2 deletions src/MsBuildPipeLogger.Server/PipeBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,24 @@ private bool TakeBuffer()
{
if (_current == null)
{
if (_queue.IsCompleted)
// Take() can throw when marked as complete from another thread
// https://docs.microsoft.com/en-us/dotnet/api/system.collections.concurrent.blockingcollection-1.take?view=netcore-3.1
try
{
_current = _queue.Take();
}
catch (ObjectDisposedException)
{
return false;
}
catch (OperationCanceledException)
{
return false;
}
catch (InvalidOperationException)
{
return false;
}
_current = _queue.Take();
}
return true;
}
Expand Down

0 comments on commit d6ce605

Please sign in to comment.