diff --git a/src/main/java/org/csource/fastdfs/TrackerServer.java b/src/main/java/org/csource/fastdfs/TrackerServer.java index cab264a..bfce3b4 100644 --- a/src/main/java/org/csource/fastdfs/TrackerServer.java +++ b/src/main/java/org/csource/fastdfs/TrackerServer.java @@ -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; } } } diff --git a/src/main/java/org/csource/fastdfs/pool/ConnectionPool.java b/src/main/java/org/csource/fastdfs/pool/ConnectionPool.java index cb4b803..5e92ec5 100644 --- a/src/main/java/org/csource/fastdfs/pool/ConnectionPool.java +++ b/src/main/java/org/csource/fastdfs/pool/ConnectionPool.java @@ -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(); } }