public void handleEvent(final T channel) { try { long count = this.count; try { long res; for (;;) { res = Channels.drain(channel, count); if (res == -1 || res == count) { this.count = 0L; invokeChannelListener(channel, finishListener); return; } else if (res == 0) { return; } else if (count < Long.MAX_VALUE) { // MAX_VALUE means drain to EOF count -= res; } } } finally { this.count = count; } } catch (IOException e) { this.count = 0L; if (exceptionHandler != null) { invokeChannelExceptionHandler(channel, exceptionHandler, e); } else { IoUtils.safeShutdownReads(channel); } } }
public void handleEvent(final T channel) { try { long count = this.count; try { long res; for (;;) { res = Channels.drain(channel, count); if (res == -1 || res == count) { this.count = 0L; invokeChannelListener(channel, finishListener); return; } else if (res == 0) { return; } else if (count < Long.MAX_VALUE) { // MAX_VALUE means drain to EOF count -= res; } } } finally { this.count = count; } } catch (IOException e) { this.count = 0L; if (exceptionHandler != null) { invokeChannelExceptionHandler(channel, exceptionHandler, e); } else { IoUtils.safeShutdownReads(channel); } } }
protected void closeAction() throws IOException { sendCloseRequest(); IoUtils.safeShutdownReads(remoteConnection.getChannel()); remoteConnection.shutdownWrites(); // now these guys can't send useless messages closePendingChannels(); closeAllChannels(); remoteConnection.getRemoteConnectionProvider().removeConnectionHandler(this); }