From 7d4a350ec419a18b472d4141fcaa8d964733a9e6 Mon Sep 17 00:00:00 2001 From: Sara Itani Date: Mon, 19 Oct 2015 09:19:36 -0700 Subject: [PATCH] #548 Debugger retry logic continues attempting to connect even though the user has already forcefully closed the process --- .../Debugger/Communication/DebuggerConnection.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Nodejs/Product/Nodejs/Debugger/Communication/DebuggerConnection.cs b/Nodejs/Product/Nodejs/Debugger/Communication/DebuggerConnection.cs index 1130e425e..30d6cd5e8 100644 --- a/Nodejs/Product/Nodejs/Debugger/Communication/DebuggerConnection.cs +++ b/Nodejs/Product/Nodejs/Debugger/Communication/DebuggerConnection.cs @@ -36,7 +36,8 @@ sealed class DebuggerConnection : IDebuggerConnection { private readonly INetworkClientFactory _networkClientFactory; private INetworkClient _networkClient; private readonly object _networkClientLock = new object(); - private volatile Version _nodeVersion; + private volatile Version _nodeVersion; + private bool _isClosed = false; public DebuggerConnection(INetworkClientFactory networkClientFactory) { Utilities.ArgumentNotNull("networkClientFactory", networkClientFactory); @@ -51,8 +52,10 @@ public void Dispose() { /// /// Close connection. /// - public void Close() { - lock (_networkClientLock) { + public void Close() { + _isClosed = true; + + lock (_networkClientLock) { if (_networkClient != null) { _networkClient.Dispose(); _networkClient = null; @@ -119,7 +122,7 @@ public void Connect(Uri uri) { lock (_networkClientLock) { int connection_attempts = 0; const int MAX_ATTEMPTS = 5; - while (true) { + while (!_isClosed) { connection_attempts++; try { // TODO: This currently results in a call to the synchronous TcpClient