Fix a bug that a TCPHandler may be shutdown immediately

after creation.

Becuase we put handler.Start() call after timeout check and
lastActivity is initialized in Start(), this will lead to a
incorrect timeout.

Also because we will call handler.Start() right after the
constructor and timeout check, so it makes no difference
where we put the initializtion of lastActivity. We won't do
this again in Start() because DateTime.Now will consumes a
lot of cpu time.
This commit is contained in:
noisyfox
2016-09-17 16:21:03 +10:00
parent 390144351a
commit 063cf111cb
@@ -173,6 +173,8 @@ namespace Shadowsocks.Controller
this._config = config;
this._tcprelay = tcprelay;
this._connection = socket;
lastActivity = DateTime.Now;
}
public void CreateRemote()
@@ -195,7 +197,6 @@ namespace Shadowsocks.Controller
_firstPacket = firstPacket;
_firstPacketLength = length;
HandshakeReceive();
lastActivity = DateTime.Now;
}
private void CheckClose()