Skip to content

Commit

Permalink
Better protection for disposed pipe from caller
Browse files Browse the repository at this point in the history
  • Loading branch information
daveaglick committed Sep 20, 2018
1 parent 52a3068 commit a7a7ccd
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/MsBuildPipeLogger.Server/PipeLoggerServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public PipeLoggerServer(PipeStream pipeStream)
{
// The client broke the stream so we're done
}
catch (ObjectDisposedException)
{
// The pipe was disposed by the caller
}

// Add a final 0 (BinaryLogRecordKind.EndOfFile) into the stream in case the BuildEventArgsReader is waiting for a read
Buffer.Write(new byte[1] { 0 }, 0, 1);
Expand All @@ -69,20 +73,12 @@ public bool Read()
return false;
}

try
BuildEventArgs args = _buildEventArgsReader.Read();
if (args != null)
{
BuildEventArgs args = _buildEventArgsReader.Read();
if (args != null)
{
Dispatch(args);
return true;
}
Dispatch(args);
return true;
}
catch (EndOfStreamException)
{
// Nothing else to read
}

return false;
}

Expand Down

0 comments on commit a7a7ccd

Please sign in to comment.