if (key != null) key.interestOps(SelectionKey.OP_READ);
} catch (CancelledKeyException ckx) {
try {
- if ( key != null && key.attachment() != null ) {
- KeyAttachment ka = (KeyAttachment)key.attachment();
- ka.setError(true); //set to collect this socket immediately
+ if ( att != null ) {
+ att.setError(true); //set to collect this socket immediately
+ att.setWakeUp(false);
}
- socket.getIOChannel().socket().close();
- socket.close();
- att.setWakeUp(false);
+ try {socket.close();}catch (Exception ignore){}
+ if ( socket.isOpen() ) socket.close(true);
} catch (Exception ignore) {}
}
}
* @todo Implement this java.nio.channels.Channel method
*/
public void close() throws IOException {
+ getIOChannel().socket().close();
sc.close();
}
public void close(boolean force) throws IOException {
- close();
+ if (isOpen() || force ) close();
}
/**
* Tells whether or not this channel is open.
KeyAttachment ka = (KeyAttachment)key.attachment();
ka.setError(true); //set to collect this socket immediately
}
- socket.getIOChannel().socket().close();
- socket.close();
+ try {socket.close();}catch (Exception ignore){}
+ if ( socket.isOpen() ) socket.close(true);
} catch ( Exception ignore ) {}
}
}
if ((event) && (handler.event(socket, error) == Handler.SocketState.CLOSED)) {
// Close socket and pool
try {
- socket.getIOChannel().socket().close();
- socket.close();
+ try {socket.close();}catch (Exception ignore){}
+ if ( socket.isOpen() ) socket.close(true);
}catch ( Exception x ) {
log.error("",x);
}
} else if ((!event) && (handler.process(socket) == Handler.SocketState.CLOSED)) {
// Close socket and pool
try {
- socket.getIOChannel().socket().close();
- socket.close();
+ try {socket.close();}catch (Exception ignore){}
+ if ( socket.isOpen() ) socket.close(true);
}catch ( Exception x ) {
log.error("",x);
}
if (handler.process(socket) == Handler.SocketState.CLOSED) {
// Close socket and pool
try {
- socket.getIOChannel().socket().close();
- socket.close();
+ try {socket.close();}catch (Exception ignore){}
+ if ( socket.isOpen() ) socket.close(true);
} catch ( Exception x ) {
log.error("",x);
}
if (handler.event(socket, error) == Handler.SocketState.CLOSED) {
// Close socket and pool
try {
- socket.getIOChannel().socket().close();
- socket.close();
+ try {socket.close();}catch (Exception ignore){}
+ if ( socket.isOpen() ) socket.close(true);
} catch ( Exception x ) {
log.error("",x);
}