@Override public XnioIoThread getIoThread() { return channel.getIoThread(); }
@Override public XnioIoThread getIoThread() { if(channel == null) { return null; } return channel.getIoThread(); }
@Override public XnioIoThread getWriteThread() { return delegate.getIoThread(); }
@Override public XnioIoThread getReadThread() { return delegate.getIoThread(); }
@Override public XnioIoThread getIoThread() { return connection.getIoThread(); }
/** * Resume the receive of new frames via {@link #receive()} */ public synchronized void resumeReceives() { receivesSuspended = false;if(Thread.currentThread() == channel.getIoThread()) { doResume(); } else { channel.getIoThread().execute(new Runnable() { @Override public void run() { doResume(); } }); } }
private void handleResumeTimeout() { Integer timeout = getTimeout(); if (timeout == null || timeout <= 0) { return; } long currentTime = System.currentTimeMillis(); expireTime = currentTime + timeout; XnioExecutor.Key key = handle; if (key == null) { handle = connection.getIoThread().executeAfter(timeoutCommand, timeout, TimeUnit.MILLISECONDS); } } }
private void handleResumeTimeout() { Integer timeout = getTimeout(); if (timeout == null || timeout <= 0) { return; } long currentTime = System.currentTimeMillis(); expireTime = currentTime + timeout; XnioExecutor.Key key = handle; if (key == null) { handle = connection.getIoThread().executeAfter(timeoutCommand, timeout, TimeUnit.MILLISECONDS); } } }
/** * Suspend the receive of new frames via {@link #receive()} */ public synchronized void suspendReceives() { receivesSuspended = true; if (receiver == null) { if(Thread.currentThread() == channel.getIoThread()) { channel.getSourceChannel().suspendReads(); } else { channel.getIoThread().execute(new Runnable() { @Override public void run() { channel.getSourceChannel().suspendReads(); } }); } } }
public void flush() { if (!flushingSenders) { if(channel.getIoThread() == Thread.currentThread()) { flushSenders(); } else { runInIoThread(new Runnable() { @Override public void run() { flushSenders(); } }); } } }
private void runWriteListener() { try { delegate.getIoThread().execute(new Runnable() { @Override public void run() { writeReadyHandler.writeReady(); } }); } catch (Throwable e) { //will only happen on shutdown IoUtils.safeClose(connection, delegate); UndertowLogger.REQUEST_IO_LOGGER.debugf(e, "Failed to queue read listener invocation"); } }
private void runReadListener(final boolean resumeInListener) { try { if(readListenerInvocationCount++ == MAX_READ_LISTENER_INVOCATIONS) { UndertowLogger.REQUEST_LOGGER.sslReadLoopDetected(this); IoUtils.safeClose(connection, delegate); close(); return; } if(resumeInListener) { delegate.getIoThread().execute(runReadListenerAndResumeCommand); } else { delegate.getIoThread().execute(runReadListenerCommand); } } catch (Throwable e) { //will only happen on shutdown IoUtils.safeClose(connection, delegate); UndertowLogger.REQUEST_IO_LOGGER.debugf(e, "Failed to queue read listener invocation"); } }
/** * Construct a new instance. * * @param delegate the underlying connection */ UndertowSslConnection(StreamConnection delegate, SSLEngine engine, ByteBufferPool bufferPool) { super(delegate.getIoThread()); this.delegate = delegate; this.engine = engine; sslConduit = new SslConduit(this, delegate, engine, bufferPool, new HandshakeCallback()); setSourceConduit(sslConduit); setSinkConduit(sslConduit); }
public void send(final Pooled<ByteBuffer> pooled, final boolean close) { connection.getIoThread().execute(() -> { synchronized (queue) { XnioExecutor.Key heartKey1 = RemoteWriteListener.this.heartKey;
AddressWrappedConnection(StreamConnection delegate, SocketAddress source, SocketAddress dest) { super(delegate.getIoThread()); this.delegate = delegate; this.source = source; this.dest = dest; setSinkConduit(delegate.getSinkChannel().getConduit()); setSourceConduit(delegate.getSourceChannel().getConduit()); }
JsseSslConnection(final StreamConnection streamConnection, final SSLEngine engine, final Pool<ByteBuffer> socketBufferPool, final Pool<ByteBuffer> applicationBufferPool) { super(streamConnection.getIoThread()); this.streamConnection = streamConnection; conduit = new JsseStreamConduit(this, engine, streamConnection.getSourceChannel().getConduit(), streamConnection.getSinkChannel().getConduit(), socketBufferPool, applicationBufferPool); setSourceConduit(conduit); setSinkConduit(conduit); }
JsseSslStreamConnection(StreamConnection connection, SSLEngine sslEngine, final Pool<ByteBuffer> socketBufferPool, final Pool<ByteBuffer> applicationBufferPool, final boolean startTls) { super(connection.getIoThread()); this.connection = connection; final StreamSinkConduit sinkConduit = connection.getSinkChannel().getConduit(); final StreamSourceConduit sourceConduit = connection.getSourceChannel().getConduit(); sslConduitEngine = new JsseSslConduitEngine(this, sinkConduit, sourceConduit, sslEngine, socketBufferPool, applicationBufferPool); tls = ! startTls; setSinkConduit(new JsseSslStreamSinkConduit(sinkConduit, sslConduitEngine, tls)); setSourceConduit(new JsseSslStreamSourceConduit(sourceConduit, sslConduitEngine, tls)); }
b.clear(); if (res == 0) { final XnioExecutor.Key key = WorkerUtils.executeAfter(connection.getIoThread(), new Runnable() { @Override public void run() {
@Override public void run() { handle = null; if (expireTime == -1) { return; } long current = System.currentTimeMillis(); if (current < expireTime) { //timeout has been bumped, re-schedule handle = WorkerUtils.executeAfter(connection.getIoThread(),timeoutCommand, (expireTime - current) + FUZZ_FACTOR, TimeUnit.MILLISECONDS); return; } UndertowLogger.REQUEST_LOGGER.tracef("Timing out channel %s due to inactivity", connection.getSourceChannel()); IoUtils.safeClose(connection); if (connection.getSourceChannel().isReadResumed()) { ChannelListeners.invokeChannelListener(connection.getSourceChannel(), connection.getSourceChannel().getReadListener()); } if (connection.getSinkChannel().isWriteResumed()) { ChannelListeners.invokeChannelListener(connection.getSinkChannel(), connection.getSinkChannel().getWriteListener()); } } };
newRequest(); channel.getIoThread().execute(this); } else { while (true) {