Cover closing remote connection when socket is disposed.

This commit is contained in:
2020-10-17 00:19:31 +01:00
parent 425097b3b6
commit 93f43423a5
3 changed files with 18 additions and 7 deletions

View File

@@ -3,8 +3,7 @@
<component name="ContentModelStore">
<e p="$USER_HOME$/.cache/JetBrains/Rider2020.2/extResources" t="IncludeRecursive" />
<e p="$USER_HOME$/.cache/JetBrains/Rider2020.2/resharper-host/local/Transient/Rider/v202/SolutionCaches/_Aaru.232757112.00" t="ExcludeRecursive" />
<e p="$APPLICATION_CONFIG_DIR$/consoles/db" t="IncludeRecursive" />
<e p="$APPLICATION_CONFIG_DIR$/extensions" t="IncludeRecursive" />
<e p="$USER_HOME$/.config/git/ignore" t="IncludeRecursive" />
<e p="$APPLICATION_PLUGINS_DIR$/puppet/lib/stubs" t="IncludeRecursive" />
<e p="$USER_HOME$/.nuget/packages/microsoft.net.test.sdk/16.4.0/build/netcoreapp2.1" t="Include">
<e p="Microsoft.NET.Test.Sdk.Program.cs" t="Include" />

View File

@@ -8,7 +8,5 @@
<content url="file://$USER_HOME$/.nuget/packages/nunit3testadapter/3.15.1/build/netcoreapp2.0/nunit.engine.dll" />
<content url="file://$MODULE_DIR$/../.." />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="R User Library" level="project" />
<orderEntry type="library" name="R Skeletons" level="application" />
</component>
</module>

View File

@@ -260,10 +260,17 @@ namespace Aaru.Devices.Remote
public void Dispose() => Disconnect();
public void Disconnect()
{
try
{
_socket.Shutdown(SocketShutdown.Both);
_socket.Close();
}
catch(ObjectDisposedException)
{
// Ignore if already disposed
}
}
public DeviceInfo[] ListDevices()
{
@@ -1415,7 +1422,14 @@ namespace Aaru.Devices.Remote
byte[] buf = Marshal.StructureToByteArrayLittleEndian(cmdPkt);
try
{
_socket.Send(buf, SocketFlags.None);
}
catch(ObjectDisposedException)
{
// Ignore if already disposed
}
}
}
}