Skip to content

Commit

Permalink
Update NETCOREAPP2_1 ifdefs (#6538)
Browse files Browse the repository at this point in the history
We actually meant 'or higher' and now that's expressible, so doing so.

Should fix the hang that held up dotnet/installer#10804.
  • Loading branch information
rainersigwald committed Jun 8, 2021
1 parent f1675f8 commit bf62538
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ private Stream TryConnectToProcess(int nodeProcessId, int timeout, Handshake han

CommunicationsUtilities.Trace("Reading handshake from pipe {0}", pipeName);

#if NETCOREAPP2_1 || MONO
#if NETCOREAPP2_1_OR_GREATER || MONO
nodeStream.ReadEndOfHandshakeSignal(true, timeout);
#else
nodeStream.ReadEndOfHandshakeSignal(true);
Expand Down
2 changes: 0 additions & 2 deletions src/MSBuild.UnitTests/ValidateAssemblyLoadContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public override bool Execute()
// This probably doesn't need to be how it is forever: https://github.com/microsoft/msbuild/issues/5041
if (thisLoadContext.GetType().FullName == typeof(MSBuildLoadContext).FullName)
{
#if NETCOREAPP && !NETCOREAPP2_1 // TODO: enable this functionality when targeting .NET Core 3.0+
if (!thisLoadContext.Name.EndsWith(typeof(ValidateAssemblyLoadContext).Assembly.GetName().Name + ".dll"))
{
Log.LogError($"Unexpected AssemblyLoadContext name: \"{thisLoadContext.Name}\", but the current executing assembly was {typeof(ValidateAssemblyLoadContext).Assembly.GetName().Name}");
Expand All @@ -32,7 +31,6 @@ public override bool Execute()
{
Log.LogMessage(MessageImportance.High, $"Task {nameof(ValidateAssemblyLoadContext)} loaded in AssemblyLoadContext named {thisLoadContext.Name}");
}
#endif
}
else
{
Expand Down
8 changes: 4 additions & 4 deletions src/Shared/CommunicationsUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,14 @@ internal static void WriteIntForHandshake(this PipeStream stream, int value)
}

internal static void ReadEndOfHandshakeSignal(this PipeStream stream, bool isProvider
#if NETCOREAPP2_1 || MONO
#if NETCOREAPP2_1_OR_GREATER || MONO
, int timeout
#endif
)
{
// Accept only the first byte of the EndOfHandshakeSignal
int valueRead = stream.ReadIntForHandshake(null
#if NETCOREAPP2_1 || MONO
#if NETCOREAPP2_1_OR_GREATER || MONO
, timeout
#endif
);
Expand All @@ -363,14 +363,14 @@ internal static void WriteIntForHandshake(this PipeStream stream, int value)
/// If specified, leading byte matches one in the supplied array if any, returns rejection byte and throws IOException.
/// </summary>
internal static int ReadIntForHandshake(this PipeStream stream, byte? byteToAccept
#if NETCOREAPP2_1 || MONO
#if NETCOREAPP2_1_OR_GREATER || MONO
, int timeout
#endif
)
{
byte[] bytes = new byte[4];

#if NETCOREAPP2_1 || MONO
#if NETCOREAPP2_1_OR_GREATER || MONO
if (!NativeMethodsShared.IsWindows)
{
// Enforce a minimum timeout because the Windows code can pass
Expand Down
6 changes: 3 additions & 3 deletions src/Shared/NodeEndpointOutOfProcBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal abstract class NodeEndpointOutOfProcBase : INodeEndpoint
{
#region Private Data

#if NETCOREAPP2_1 || MONO
#if NETCOREAPP2_1_OR_GREATER || MONO
/// <summary>
/// The amount of time to wait for the client to connect to the host.
/// </summary>
Expand Down Expand Up @@ -386,7 +386,7 @@ private void PacketPumpProc()
for (int i = 0; i < handshakeComponents.Length; i++)
{
int handshakePart = _pipeServer.ReadIntForHandshake(i == 0 ? (byte?)CommunicationsUtilities.handshakeVersion : null /* this will disconnect a < 16.8 host; it expects leading 00 or F5 or 06. 0x00 is a wildcard */
#if NETCOREAPP2_1 || MONO
#if NETCOREAPP2_1_OR_GREATER || MONO
, ClientConnectTimeout /* wait a long time for the handshake from this side */
#endif
);
Expand All @@ -403,7 +403,7 @@ private void PacketPumpProc()
if (gotValidConnection)
{
// To ensure that our handshake and theirs have the same number of bytes, receive and send a magic number indicating EOS.
#if NETCOREAPP2_1 || MONO
#if NETCOREAPP2_1_OR_GREATER || MONO
_pipeServer.ReadEndOfHandshakeSignal(false, ClientConnectTimeout); /* wait a long time for the handshake from this side */
#else
_pipeServer.ReadEndOfHandshakeSignal(false);
Expand Down

0 comments on commit bf62538

Please sign in to comment.