feature: add socket connection pool

dev
tanyawen 2019-12-27 23:25:16 +08:00
parent 3ad9f94a69
commit 145d80c6ac
1 changed files with 2 additions and 3 deletions

View File

@ -113,10 +113,10 @@ public class ConnectionManager {
if (trackerServer == null || trackerServer.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()) {
try {
lock.lock();
ConnectionInfo connectionInfo = new ConnectionInfo(trackerServer.getSocket(),trackerServer.getInetSocketAddress(),System.currentTimeMillis(),true);
freeConnections.add(connectionInfo);
freeCount.incrementAndGet();
condition.signal();
@ -124,8 +124,7 @@ public class ConnectionManager {
lock.unlock();
}
} else {
trackerServer.close();
totalCount.decrementAndGet();
closeConnection(connectionInfo);
}
}