Skip to content

Commit 4731a4b

Browse files
committed
fixed the bug of tcp server stop action.
1 parent 48ecc0a commit 4731a4b

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

build/version.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup Condition="'$(AssemblyName)'=='GodSharp.Socket'">
33
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
4-
<Version>2019.1.0.0-preview2</Version>
5-
<FileVersion>2019.1.0.0-preview</FileVersion>
4+
<Version>2019.1.0.0-preview3</Version>
5+
<FileVersion>2019.1.0.0-preview3</FileVersion>
66
</PropertyGroup>
77
</Project>

src/GodSharp.Socket/Tcp/TcpServer.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,14 @@ private void AcceptCallback(IAsyncResult result)
141141
bool error = false;
142142
try
143143
{
144+
if (!Running || stopping) return;
145+
144146
Socket socket = Instance.EndAccept(result);
145147

146148
if (stopping) return;
147149

148150
BeginAccept();
149-
151+
150152
ITcpConnection connection = new TcpConnection(socket) { OnConnected = OnConnectedHandler, OnReceived = OnReceivedHandler, OnDisconnected = OnDisconnectedHandler, OnException = OnExceptionHandler };
151153
connection.Start();
152154

@@ -178,7 +180,11 @@ private void RemoveListener(string key)
178180

179181
try
180182
{
181-
if (existed) Connections[key].Stop();
183+
if (existed)
184+
{
185+
Connections[key].Stop();
186+
Connections[key] = null;
187+
}
182188
}
183189
catch (Exception ex)
184190
{

0 commit comments

Comments
 (0)