feature: add socket connection pool
parent
3ad9f94a69
commit
145d80c6ac
|
@ -113,10 +113,10 @@ public class ConnectionManager {
|
||||||
if (trackerServer == null || trackerServer.getSocket() == null) {
|
if (trackerServer == null || trackerServer.getSocket() == null) {
|
||||||
return;
|
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() - trackerServer.getLastAccessTime()) < ClientGlobal.getG_connection_pool_max_idle_time()) {
|
||||||
try {
|
try {
|
||||||
lock.lock();
|
lock.lock();
|
||||||
ConnectionInfo connectionInfo = new ConnectionInfo(trackerServer.getSocket(),trackerServer.getInetSocketAddress(),System.currentTimeMillis(),true);
|
|
||||||
freeConnections.add(connectionInfo);
|
freeConnections.add(connectionInfo);
|
||||||
freeCount.incrementAndGet();
|
freeCount.incrementAndGet();
|
||||||
condition.signal();
|
condition.signal();
|
||||||
|
@ -124,8 +124,7 @@ public class ConnectionManager {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
trackerServer.close();
|
closeConnection(connectionInfo);
|
||||||
totalCount.decrementAndGet();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue