Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/OneScript.DebugServices/ReconnectableDebugController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public class ReconnectableDebugController : IDebugController
public ReconnectableDebugController(int port)
{
_port = port;
_listener = TcpListener.Create(_port);
}

public IBreakpointManager BreakpointManager => _breakpointManager;
Expand All @@ -64,6 +63,7 @@ public void Init()

private void CreateSession()
{
_listener = TcpListener.Create(_port);
_channel = new DelayedConnectionChannel(_listener);
_server = new DefaultMessageServer<RpcCall>(_channel)
{
Expand Down Expand Up @@ -125,13 +125,26 @@ private void DisposeSession()
_channel?.Dispose();
_callbackService?.Dispose();

if (_listener != null)
{
try
{
_listener.Stop();
}
catch
{
// Listener may already be stopped
}
}

_channel = null;
_callbackService = null;
_server = null;
_dispatcher = null;
_debugger = null;
_threadManager = null;
_breakpointManager = null;
_listener = null;
}

private void ThreadManagerOnThreadStopped(object sender, ThreadStoppedEventArgs e)
Expand Down Expand Up @@ -190,9 +203,6 @@ public void Dispose()

DisposeSession();

_listener?.Stop();
_listener = null;

_disposed = true;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/VSCode.DebugAdapter/DebugeeProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ public void HandleDisconnect(bool terminate)
return;
}
_debugger.Disconnect(terminate);
_debugger = null;

var mustKill = terminate && !_attachMode;

Expand Down