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