protected void fastCloseSock(SocketChannel sc) { if (sc != null) { try { // Hard close immediately, discarding buffers sc.socket().setSoLinger(true, 0); } catch (SocketException e) { LOG.warn("Unable to set socket linger to 0, socket close" + " may stall in CLOSE_WAIT", e); } NIOServerCnxn.closeSock(sc); } } }
/** * Close resources associated with the sock of this cnxn. */ private void closeSock() { if (sock.isOpen() == false) { return; } LOG.debug("Closed socket connection for client " + sock.socket().getRemoteSocketAddress() + (sessionId != 0 ? " which had sessionid 0x" + Long.toHexString(sessionId) : " (no session established for client)")); closeSock(sock); }
/** * Close the cnxn and remove it from the factory cnxns list. */ @Override public void close() { setStale(); if (!factory.removeCnxn(this)) { return; } if (zkServer != null) { zkServer.removeCnxn(this); } if (sk != null) { try { // need to cancel this selection key from the selector sk.cancel(); } catch (Exception e) { if (LOG.isDebugEnabled()) { LOG.debug("ignoring exception during selectionkey cancel", e); } } } closeSock(); }
@Override public void close() { factory.removeCnxn(this); if (zkServer != null) { zkServer.removeCnxn(this); } closeSock(); if (sk != null) { try { // need to cancel this selection key from the selector sk.cancel(); } catch (Exception e) { if (LOG.isDebugEnabled()) { LOG.debug("ignoring exception during selectionkey cancel", e); } } } }