feature: add socket connection pool

This commit is contained in:
tanyawen
2019-12-28 01:43:42 +08:00
parent 3c61ba0e7a
commit 6aa61096b2
4 changed files with 34 additions and 6 deletions

View File

@@ -109,12 +109,11 @@ public class ConnectionManager {
}
}
public void freeConnection(TrackerServer trackerServer) throws IOException {
if (trackerServer == null || trackerServer.getSocket() == null) {
public void freeConnection(ConnectionInfo connectionInfo) throws IOException {
if (connectionInfo == null || connectionInfo.getSocket() == null) {
return;
}
ConnectionInfo connectionInfo = new ConnectionInfo(trackerServer.getSocket(),trackerServer.getInetSocketAddress(),System.currentTimeMillis(),true);
if ((System.currentTimeMillis() - trackerServer.getLastAccessTime()) < ClientGlobal.getG_connection_pool_max_idle_time()) {
if ((System.currentTimeMillis() - connectionInfo.getLastAccessTime()) < ClientGlobal.getG_connection_pool_max_idle_time()) {
try {
lock.lock();
freeConnections.add(connectionInfo);