Refine search
private void close0() { if (!closed) { closed = true; for (;;) { AcquireTask task = pendingAcquireQueue.poll(); if (task == null) { break; } ScheduledFuture<?> f = task.timeoutFuture; if (f != null) { f.cancel(false); } task.promise.setFailure(new ClosedChannelException()); } acquiredChannelCount.set(0); pendingAcquireCount = 0; // Ensure we dispatch this on another Thread as close0 will be called from the EventExecutor and we need // to ensure we will not block in a EventExecutor. GlobalEventExecutor.INSTANCE.execute(new Runnable() { @Override public void run() { FixedChannelPool.super.close(); } }); } } }
/** * Fail all buffered writes that are left. See * <a href="https://github.com/netty/netty/issues/308>#308</a> for more details. */ @Override public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { Throwable cause = null; for (;;) { MessageEvent ev = queue.poll(); if (ev == null) { break; } if (cause == null) { cause = new ClosedChannelException(); } ev.getFuture().setFailure(cause); } if (cause != null) { Channels.fireExceptionCaught(ctx.getChannel(), cause); } super.channelClosed(ctx, e); }
pendingWrite = pendingUnencryptedWrites.peek(); if (pendingWrite == null) { break; if (outAppBuf == null) { pendingUnencryptedWrites.remove(); offerEncryptedWriteRequest( new DownstreamMessageEvent( } finally { if (!outAppBuf.hasRemaining()) { pendingUnencryptedWrites.remove(); future = succeededFuture(channel); } else { future = pendingWrite.future; Exception cause = channel.isOpen() ? new SSLException("SSLEngine already closed") : new ClosedChannelException(); pendingWrite.future.setFailure(cause); pendingWrite.future.setFailure(cause);
assertEquals(0, _eventQueue.size()); e.printStackTrace(); fail("Caught ClosedChannelException."); if (lastReadRet == TransportReturnCodes.READ_PING || lastReadRet == TransportReturnCodes.READ_WOULD_BLOCK) continue; _eventQueue.add(new ReadEvent(buffer, _channel, lastReadRet)); } while(currentTimeUsec < stopTimeUsec && (expectedEventCount == 0 || _eventQueue.size() < expectedEventCount)); assertEquals(expectedEventCount, _eventQueue.size());
try { for (;;) { MessageEvent e = writeBuffer.poll(); if (e == null) { break; fireMessageReceived(pairedChannel, e.getMessage()); e.getFuture().setSuccess(); fireWriteComplete(this, 1); cause = new NotYetConnectedException(); } else { cause = new ClosedChannelException(); MessageEvent e = writeBuffer.poll(); if (e == null) { break; e.getFuture().setFailure(cause); fireExceptionCaught(this, cause);
@Override protected void needsFillInterest() throws IOException { try(Locker.Lock lock = _locker.lock()) { if (_closed) throw new ClosedChannelException(); ByteBuffer in = _inQ.peek(); if (BufferUtil.hasContent(in) || in==EOF) execute(_runFillable); } }
assertEquals(0, _eventQueue.size()); e.printStackTrace(); fail("Caught ClosedChannelException."); if (expectedEventCount > 0 && _eventQueue.size() == expectedEventCount) assertEquals(expectedEventCount, _eventQueue.size());
protected void lastDataRead() { if(!lastFrameSent) { markReadsBroken(new ClosedChannelException()); markWritesBroken(new ClosedChannelException()); } lastFrameReceived = true; lastFrameSent = true; IoUtils.safeClose(this); }
public int write(final ByteBuffer src) throws IOException { if (anyAreSet(state, FLAG_CLOSE_COMPLETE)) { throw new ClosedChannelException(); } int remaining = src.remaining(); src.position(src.position() + remaining); return remaining; }
@Override public void write(int b) throws IOException { throw new ClosedChannelException(); } };
future.setFailure(new ClosedChannelException()); close(channel, succeededFuture(channel)); return; future.setSuccess(); fireChannelBound(channel, localAddress); fireChannelConnected(channel, remoteAddress); } catch (IOException e) { if (future != null) { future.setFailure(e); close(channel, succeededFuture(channel));
@Override public long transferFrom(final StreamSourceChannel source, final long count, final ByteBuffer throughBuffer) throws IOException { if (anyAreSet(state, FLAG_WRITES_SHUTDOWN)) { throw new ClosedChannelException(); } return IoUtils.transfer(source, count, throughBuffer, new ConduitWritableByteChannel(this)); }
if (allAreSet(oldState, FLAG_SHUTDOWN)) { next.terminateWrites(); throw new ClosedChannelException(); IoUtils.safeClose(connection); throw e;
public void operationComplete(ChannelFuture f) throws Exception { if (!cf.isDone()) { cf.setFailure(new ClosedChannelException()); } } });
public long write(final ByteBuffer[] srcs, final int offs, final int len) throws IOException { if (allAreSet(state, WRITE_FLAG_SHUTDOWN)) { throw new ClosedChannelException(); } if (allAreClear(state, FLAG_TLS)) { return sinkConduit.write(srcs, offs, len); } else { final long r1 = Buffers.remaining(srcs, offs, len); performIO(IO_GOAL_WRITE, srcs, offs, len, NO_BUFFERS, 0, 0); return (r1 - Buffers.remaining(srcs, offs, len)); } }
@Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { // Make sure the handshake future is notified when a connection has // been closed during handshake. synchronized (handshakeLock) { if (handshaking) { cancelHandshakeTimeout(); handshakeFuture.setFailure(new ClosedChannelException()); } } try { super.channelDisconnected(ctx, e); } finally { unwrapNonAppData(ctx, e.getChannel(), false); closeEngine(); } }
if(anyAreSet(state, FLAG_CLOSED)) { throw new ClosedChannelException(); if(anyAreSet(state, FLAG_READ_REQUIRES_WRITE)) { doWrap(null, 0, 0); if(allAreClear(state, FLAG_WRITE_REQUIRES_READ)) { //unless a wrap is immediately required we just return return 0; } else if (result.getStatus() == SSLEngineResult.Status.BUFFER_OVERFLOW) { UndertowLogger.REQUEST_LOGGER.sslBufferOverflow(this); IoUtils.safeClose(delegate); } else if (this.dataToUnwrap.getBuffer().hasRemaining() && dataToUnwrap.getBuffer().remaining() != dataToUnwrapLength) { state |= FLAG_DATA_TO_UNWRAP;
void beginHandshake() throws IOException { final int state = this.state; if (anyAreSet(state, READ_FLAG_EOF | WRITE_FLAG_SHUTDOWN)) { throw new ClosedChannelException(); } if (allAreClear(state, FLAG_TLS)) { this.state = state | FLAG_TLS; } engine.beginHandshake(); }
OutputStream out = channel.getOutputStream(); if (out == null) { Exception e = new ClosedChannelException(); future.setFailure(e); if (iothread) { fireExceptionCaught(channel, e); } else { fireExceptionCaughtLater(channel, e); future.setSuccess(); if (iothread) { fireWriteComplete(channel, length); } else { fireWriteCompleteLater(channel, length); SOCKET_CLOSED_MESSAGE.matcher( String.valueOf(t.getMessage())).matches()) { t = new ClosedChannelException(); future.setFailure(t); if (iothread) { fireExceptionCaught(channel, t);
future.setSuccess(); if (changed) { if (iothread) { fireChannelInterestChanged(channel); } else { fireChannelInterestChangedLater(channel); future.setSuccess(); if (changed) { fireChannelInterestChanged(channel); ClosedChannelException cce = new ClosedChannelException(); future.setFailure(cce); fireExceptionCaught(channel, cce); } catch (Throwable t) {