Skip to content

Commit

Permalink
fixed bug where connections were not closed
Browse files Browse the repository at this point in the history
also added test cases for this
  • Loading branch information
piksel committed Oct 4, 2015
1 parent 29d1d8b commit cc6d963
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion NemesisTest/NemesisTest.csproj
Expand Up @@ -12,7 +12,7 @@
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<AssemblyVersion>1.3.15258.125</AssemblyVersion>
<AssemblyVersion>1.3.15277.134</AssemblyVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
12 changes: 10 additions & 2 deletions NemesisTest/Program.cs
Expand Up @@ -51,14 +51,22 @@ static void Main(string[] args)
Thread.Sleep(2000);

var cmdTest = "test";
_log.Info("Sending command \"{0}\" to server A ({1})", cmdTest, serverGuidA);
_log.Info("Sending command \"{0}\" (1/2) to server A ({1})", cmdTest, serverGuidA);
var response = client.SendCommand(cmdTest, serverGuidA);
_log.Info("Got response: {0}", response.Result);

_log.Info("Sending command \"{0}\" from server A to client", cmdTest);
_log.Info("Sending command \"{0}\" (2/2) to server A ({1})", cmdTest, serverGuidA);
response = client.SendCommand(cmdTest, serverGuidA);
_log.Info("Got response: {0}", response.Result);

_log.Info("Sending command \"{0}\" (1/2) from server A to client", cmdTest);
var response2 = serverA.SendCommand(cmdTest);
_log.Info("Got response: {0}", response2.Result);

_log.Info("Sending command \"{0}\" (2/2) from server A to client", cmdTest);
response2 = serverA.SendCommand(cmdTest);
_log.Info("Got response: {0}", response2.Result);


_log.Info("Sending command \"{0}\" to server B ({1})", cmdTest, serverGuidB);
var response3 = client.SendCommand(cmdTest, serverGuidB);
Expand Down
4 changes: 2 additions & 2 deletions NemesisTest/Properties/AssemblyInfo.cs
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.15258.125")]
[assembly: AssemblyFileVersion("1.3.15258.125")]
[assembly: AssemblyVersion("1.3.15277.134")]
[assembly: AssemblyFileVersion("1.3.15277.134")]
2 changes: 2 additions & 0 deletions libnemesis/Client.cs
Expand Up @@ -108,6 +108,7 @@ private void HandleAsyncConnection(IAsyncResult result)
if (commandQueue.TryDequeue(out serverCommand))
{
handleRemoteCommand(stream, serverCommand);
stream.Close();
}
else
{
Expand All @@ -119,6 +120,7 @@ private void HandleAsyncConnection(IAsyncResult result)
{
_log.Info("Waiting for command...");
handleLocalCommand(stream, serverId);
stream.Close();
}
else
{
Expand Down
1 change: 1 addition & 0 deletions libnemesis/Common.cs
Expand Up @@ -102,6 +102,7 @@ protected void handleRemoteCommand(NetworkStream stream, QueuedCommand serverCom
}
}
serverCommand.ResultSource.SetResult(response);
stream.Close();
}

protected async void handleLocalCommand(NetworkStream stream, Guid remoteId)
Expand Down
4 changes: 2 additions & 2 deletions libnemesis/Properties/AssemblyInfo.cs
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.15258.110")]
[assembly: AssemblyFileVersion("1.3.15258.110")]
[assembly: AssemblyVersion("1.3.15277.116")]
[assembly: AssemblyFileVersion("1.3.15277.116")]
2 changes: 1 addition & 1 deletion libnemesis/libnemesis.csproj
Expand Up @@ -12,7 +12,7 @@
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<AssemblyVersion>1.3.15258.110</AssemblyVersion>
<AssemblyVersion>1.3.15277.116</AssemblyVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down

0 comments on commit cc6d963

Please sign in to comment.