_state = _state.toClosed(this);
if (state.isClosed())
return;
QSocket socket = _socket;
// detach any comet
if (state.isComet() || state.isCometSuspend())
getPort().cometDetach(this);
getRequest().onCloseConnection();
AsyncController controller = _controller;
_controller = null;
if (controller != null)
controller.closeImpl();
SocketLinkListener port = getPort();
if (log.isLoggable(Level.FINER)) {
if (port != null)
log.finer(dbgId() + " closing connection " + this + ", total=" + port.getConnectionCount());
else
log.finer(dbgId() + " closing connection " + this);
}
try {
getWriteStream().close();
} catch (Throwable e) {
log.log(Level.FINE, e.toString(), e);
}
try {
getReadStream().close();
} catch (Throwable e) {
log.log(Level.FINE, e.toString(), e);
}
if (socket != null) {
getPort().closeSocket(socket);
try {
socket.close();
} catch (Throwable e) {
log.log(Level.FINE, e.toString(), e);
}
}
}