Skip to content

Commit

Permalink
[Mono.Debugger.Soft] Make sure receiving thread always closes
Browse files Browse the repository at this point in the history
When we want to close the connection, setting the close flag is not enough, because a thread can be already stuck in a blocking receive, without getting to check the flag. We fix this by additionaly breaking the connection, by using socket.Shutdown.

Fixes mono#7377
  • Loading branch information
BrzVlad committed Sep 26, 2019
1 parent b9451f1 commit 2ceb935
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs
Expand Up @@ -1318,6 +1318,8 @@ class PacketWriter {
protected abstract int TransportSend (byte[] buf, int buf_offset, int len);
protected abstract void TransportSetTimeouts (int send_timeout, int receive_timeout);
protected abstract void TransportClose ();
// Shutdown breaks all communication, resuming blocking waits
protected abstract void TransportShutdown ();

internal VersionInfo Version;

Expand Down Expand Up @@ -1434,6 +1436,7 @@ class PacketWriter {

internal void Close () {
closed = true;
TransportShutdown ();
}

internal bool IsClosed {
Expand Down Expand Up @@ -2865,6 +2868,11 @@ protected override void TransportClose ()
{
socket.Close ();
}

protected override void TransportShutdown ()
{
socket.Shutdown (SocketShutdown.Both);
}
}

/* This is the interface exposed by the debugger towards the debugger agent */
Expand Down

0 comments on commit 2ceb935

Please sign in to comment.