feature: add socket connection pool
parent
145d80c6ac
commit
3c61ba0e7a
|
@ -86,12 +86,20 @@ public class TrackerServer {
|
||||||
if (ClientGlobal.g_connection_pool_enabled) {
|
if (ClientGlobal.g_connection_pool_enabled) {
|
||||||
ConnectionPool.freeConnection(this);
|
ConnectionPool.freeConnection(this);
|
||||||
} else {
|
} else {
|
||||||
if (this.sock != null) {
|
this.closeDirect();
|
||||||
try {
|
}
|
||||||
ProtoCommon.closeSocket(this.sock);
|
}
|
||||||
} finally {
|
|
||||||
this.sock = null;
|
/**
|
||||||
}
|
* close direct if not create from pool or not open pool
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public void closeDirect() throws IOException {
|
||||||
|
if (this.sock != null) {
|
||||||
|
try {
|
||||||
|
ProtoCommon.closeSocket(this.sock);
|
||||||
|
} finally {
|
||||||
|
this.sock = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class ConnectionPool {
|
||||||
ConnectionManager connectionManager = CP.get(key);
|
ConnectionManager connectionManager = CP.get(key);
|
||||||
connectionManager.closeConnection(new ConnectionInfo(trackerServer.getSocket(), trackerServer.getInetSocketAddress(),trackerServer.getLastAccessTime(),true));
|
connectionManager.closeConnection(new ConnectionInfo(trackerServer.getSocket(), trackerServer.getInetSocketAddress(),trackerServer.getLastAccessTime(),true));
|
||||||
} else {
|
} else {
|
||||||
trackerServer.close();
|
trackerServer.closeDirect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public class ConnectionPool {
|
||||||
ConnectionManager connectionManager = CP.get(key);
|
ConnectionManager connectionManager = CP.get(key);
|
||||||
connectionManager.freeConnection(trackerServer);
|
connectionManager.freeConnection(trackerServer);
|
||||||
} else {
|
} else {
|
||||||
trackerServer.close();
|
trackerServer.closeDirect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue