Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelsavara committed Jun 21, 2021
1 parent bca373a commit 74dfcb4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/libraries/Common/tests/System/Net/Http/LoopbackServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public sealed partial class LoopbackServer : GenericLoopbackServer, IDisposable
private static readonly byte[] s_newLineBytes = new byte[] { (byte)'\r', (byte)'\n' };
private static readonly byte[] s_colonSpaceBytes = new byte[] { (byte)':', (byte)' ' };

private SocketWrapper _socketWrapper;
#if TARGET_BROWSER
private ClientWebSocket _listenSocket;
#else
Expand Down Expand Up @@ -69,24 +70,27 @@ public async Task ListenAsync()
}

_uri = new Uri($"{scheme}://{host}:{localEndPoint.Port}/");
_socketWrapper = new SocketWrapper(_listenSocket);
}
catch
{
_listenSocket?.Dispose();
_socketWrapper?.Dispose();
throw;
}
}

public override void Dispose()
{
if (_listenSocket != null)
_listenSocket = null;
if (_socketWrapper != null)
{
_listenSocket.Dispose();
_listenSocket = null;
_socketWrapper.Dispose();
_socketWrapper = null;
}
}

public SocketWrapper ListenSocket => new SocketWrapper(_listenSocket);
public SocketWrapper ListenSocket => _socketWrapper;
public override Uri Address => _uri;

public static async Task CreateServerAsync(Func<LoopbackServer, Task> funcAsync, Options options = null)
Expand Down

0 comments on commit 74dfcb4

Please sign in to comment.