org.apache.tomcat.util.net.NioEndpoint Java Examples

The following examples show how to use org.apache.tomcat.util.net.NioEndpoint. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AjpNioProtocol.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
protected AjpNioProcessor createProcessor() {
    AjpNioProcessor processor = new AjpNioProcessor(proto.packetSize, (NioEndpoint)proto.endpoint);

    // 设置 adapter 对象
    processor.setAdapter(proto.adapter);
    processor.setAjpFlush(proto.getAjpFlush());
    processor.setTomcatAuthentication(proto.tomcatAuthentication);
    processor.setTomcatAuthorization(proto.getTomcatAuthorization());
    processor.setRequiredSecret(proto.requiredSecret);
    processor.setKeepAliveTimeout(proto.getKeepAliveTimeout());
    processor.setClientCertProvider(proto.getClientCertProvider());
    processor.setMaxCookieCount(proto.getMaxCookieCount());
    register(processor);
    return processor;
}
 
Example #2
Source File: InternalNioOutputBuffer.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Callback to write data from the buffer.
 */
private void flushBuffer() throws IOException {

    //prevent timeout for async,
    SelectionKey key = socket.getIOChannel().keyFor(socket.getPoller().getSelector());
    if (key != null) {
        NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment) key.attachment();
        attach.access();
    }

    //write to the socket, if there is anything to write
    if (socket.getBufHandler().getWriteBuffer().position() > 0) {
        socket.getBufHandler().getWriteBuffer().flip();
        writeToSocket(socket.getBufHandler().getWriteBuffer(),true, false);
    }
}
 
Example #3
Source File: InternalNioOutputBuffer.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param bytebuffer ByteBuffer
 * @param flip boolean
 * @return int
 * @throws IOException
 * TODO Fix non blocking write properly
 */
private synchronized int writeToSocket(ByteBuffer bytebuffer, boolean block, boolean flip) throws IOException {
    if ( flip ) bytebuffer.flip();

    int written = 0;
    NioEndpoint.KeyAttachment att = (NioEndpoint.KeyAttachment)socket.getAttachment();
    if ( att == null ) throw new IOException("Key must be cancelled");
    long writeTimeout = att.getWriteTimeout();
    Selector selector = null;
    try {
        selector = pool.get();
    } catch ( IOException x ) {
        //ignore
    }
    try {
        written = pool.write(bytebuffer, socket, selector, writeTimeout, block);
        //make sure we are flushed 
        do {
            if (socket.flush(true,selector,writeTimeout)) break;
        }while ( true );
    }finally { 
        if ( selector != null ) pool.put(selector);
    }
    if ( block ) bytebuffer.clear(); //only clear
    return written;
}
 
Example #4
Source File: InternalNioOutputBuffer.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
private synchronized void addToBB(byte[] buf, int offset, int length) throws IOException {
    while (length > 0) {
        int thisTime = length;
        if (socket.getBufHandler().getWriteBuffer().position() ==
                socket.getBufHandler().getWriteBuffer().capacity()
                || socket.getBufHandler().getWriteBuffer().remaining()==0) {
            flushBuffer();
        }
        if (thisTime > socket.getBufHandler().getWriteBuffer().remaining()) {
            thisTime = socket.getBufHandler().getWriteBuffer().remaining();
        }
        socket.getBufHandler().getWriteBuffer().put(buf, offset, thisTime);
        length = length - thisTime;
        offset = offset + thisTime;
    }
    NioEndpoint.KeyAttachment ka = (NioEndpoint.KeyAttachment)socket.getAttachment();
    if ( ka!= null ) ka.access();//prevent timeouts for just doing client writes
}
 
Example #5
Source File: NioServletOutputStream.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
protected void doFlush() throws IOException {
    NioEndpoint.KeyAttachment att =
            (NioEndpoint.KeyAttachment) channel.getAttachment();
    if (att == null) {
        throw new IOException("Key must be cancelled");
    }
    long writeTimeout = att.getWriteTimeout();
    Selector selector = null;
    try {
        selector = pool.get();
    } catch ( IOException x ) {
        //ignore
    }
    try {
        do {
            if (channel.flush(true, selector, writeTimeout)) {
                break;
            }
        } while (true);
    } finally {
        if (selector != null) {
            pool.put(selector);
        }
    }
}
 
Example #6
Source File: NioServletOutputStream.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
protected void doFlush() throws IOException {
    NioEndpoint.KeyAttachment att =
            (NioEndpoint.KeyAttachment) channel.getAttachment();
    if (att == null) {
        throw new IOException("Key must be cancelled");
    }
    long writeTimeout = att.getWriteTimeout();
    Selector selector = null;
    try {
        selector = pool.get();
    } catch ( IOException x ) {
        //ignore
    }
    try {
        do {
            if (channel.flush(true, selector, writeTimeout)) {
                break;
            }
        } while (true);
    } finally {
        if (selector != null) {
            pool.put(selector);
        }
    }
}
 
Example #7
Source File: UpgradeNioProcessor.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
public void flush() throws IOException {
    NioEndpoint.KeyAttachment att =
            (NioEndpoint.KeyAttachment) nioChannel.getAttachment();
    if (att == null) {
        throw new IOException("Key must be cancelled");
    }
    long writeTimeout = att.getTimeout();
    Selector selector = null;
    try {
        selector = pool.get();
    } catch ( IOException x ) {
        //ignore
    }
    try {
        do {
            if (nioChannel.flush(true, selector, writeTimeout)) {
                break;
            }
        } while (true);
    } finally {
        if (selector != null) {
            pool.put(selector);
        }
    }
}
 
Example #8
Source File: UpgradeNioProcessor.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public void flush() throws IOException {
    NioEndpoint.KeyAttachment att =
            (NioEndpoint.KeyAttachment) nioChannel.getAttachment();
    if (att == null) {
        throw new IOException("Key must be cancelled");
    }
    long writeTimeout = att.getTimeout();
    Selector selector = null;
    try {
        selector = pool.get();
    } catch ( IOException x ) {
        //ignore
    }
    try {
        do {
            if (nioChannel.flush(true, selector, writeTimeout)) {
                break;
            }
        } while (true);
    } finally {
        if (selector != null) {
            pool.put(selector);
        }
    }
}
 
Example #9
Source File: InternalNioOutputBuffer.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param bytebuffer ByteBuffer
 * @param flip boolean
 * @return int
 * @throws IOException
 * TODO Fix non blocking write properly
 */
private synchronized int writeToSocket(ByteBuffer bytebuffer, boolean block, boolean flip) throws IOException {
    if ( flip ) bytebuffer.flip();

    int written = 0;
    NioEndpoint.KeyAttachment att = (NioEndpoint.KeyAttachment)socket.getAttachment();
    if ( att == null ) throw new IOException("Key must be cancelled");
    long writeTimeout = att.getWriteTimeout();
    Selector selector = null;
    try {
        selector = pool.get();
    } catch ( IOException x ) {
        //ignore
    }
    try {
        written = pool.write(bytebuffer, socket, selector, writeTimeout, block);
        //make sure we are flushed
        do {
            if (socket.flush(true,selector,writeTimeout)) break;
        }while ( true );
    }finally {
        if ( selector != null ) pool.put(selector);
    }
    if ( block ) bytebuffer.clear(); //only clear
    return written;
}
 
Example #10
Source File: Http11NioProcessor.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean prepareSendfile(OutputFilter[] outputFilters) {
    String fileName = (String) request.getAttribute(
            org.apache.coyote.Constants.SENDFILE_FILENAME_ATTR);
    if (fileName != null) {
        // No entity body sent here
        outputBuffer.addActiveFilter(outputFilters[Constants.VOID_FILTER]);
        contentDelimitation = true;
        sendfileData = new NioEndpoint.SendfileData();
        sendfileData.fileName = fileName;
        sendfileData.pos = ((Long) request.getAttribute(
                org.apache.coyote.Constants.SENDFILE_FILE_START_ATTR)).longValue();
        sendfileData.length = ((Long) request.getAttribute(
                org.apache.coyote.Constants.SENDFILE_FILE_END_ATTR)).longValue() - sendfileData.pos;
        return true;
    }
    return false;
}
 
Example #11
Source File: InternalNioOutputBuffer.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
private synchronized void addToBB(byte[] buf, int offset, int length) throws IOException {
    while (length > 0) {
        int thisTime = length;
        if (socket.getBufHandler().getWriteBuffer().position() ==
                socket.getBufHandler().getWriteBuffer().capacity()
                || socket.getBufHandler().getWriteBuffer().remaining()==0) {
            flushBuffer();
        }
        if (thisTime > socket.getBufHandler().getWriteBuffer().remaining()) {
            thisTime = socket.getBufHandler().getWriteBuffer().remaining();
        }
        socket.getBufHandler().getWriteBuffer().put(buf, offset, thisTime);
        length = length - thisTime;
        offset = offset + thisTime;
    }
    NioEndpoint.KeyAttachment ka = (NioEndpoint.KeyAttachment)socket.getAttachment();
    if ( ka!= null ) ka.access();//prevent timeouts for just doing client writes
}
 
Example #12
Source File: InternalNioOutputBuffer.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Callback to write data from the buffer.
 */
private void flushBuffer() throws IOException {

    //prevent timeout for async,
    SelectionKey key = socket.getIOChannel().keyFor(socket.getPoller().getSelector());
    if (key != null) {
        NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment) key.attachment();
        attach.access();
    }

    //write to the socket, if there is anything to write
    if (socket.getBufHandler().getWriteBuffer().position() > 0) {
        socket.getBufHandler().getWriteBuffer().flip();
        writeToSocket(socket.getBufHandler().getWriteBuffer(),true, false);
    }
}
 
Example #13
Source File: Http11NioProcessor.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
protected void setCometTimeouts(SocketWrapper<NioChannel> socketWrapper) {
    // Comet support
    SelectionKey key = socketWrapper.getSocket().getIOChannel().keyFor(
            socketWrapper.getSocket().getPoller().getSelector());
    if (key != null) {
        NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment) key.attachment();
        if (attach != null)  {
            attach.setComet(comet);
            if (comet) {
                Integer comettimeout = (Integer) request.getAttribute(
                        org.apache.coyote.Constants.COMET_TIMEOUT_ATTR);
                if (comettimeout != null) {
                    attach.setTimeout(comettimeout.longValue());
                }
            }
        }
    }
}
 
Example #14
Source File: Http11NioProtocol.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
public Http11NioProcessor createProcessor() {
    Http11NioProcessor processor = new Http11NioProcessor(
            proto.getMaxHttpHeaderSize(), (NioEndpoint)proto.endpoint,
            proto.getMaxTrailerSize(), proto.getAllowedTrailerHeadersAsSet(),
            proto.getMaxExtensionSize(), proto.getMaxSwallowSize());
    processor.setAdapter(proto.adapter);
    processor.setMaxKeepAliveRequests(proto.getMaxKeepAliveRequests());
    processor.setKeepAliveTimeout(proto.getKeepAliveTimeout());
    processor.setConnectionUploadTimeout(
            proto.getConnectionUploadTimeout());
    processor.setDisableUploadTimeout(proto.getDisableUploadTimeout());
    processor.setCompressionMinSize(proto.getCompressionMinSize());
    processor.setCompression(proto.getCompression());
    processor.setNoCompressionUserAgents(proto.getNoCompressionUserAgents());
    processor.setCompressableMimeTypes(proto.getCompressableMimeTypes());
    processor.setRestrictedUserAgents(proto.getRestrictedUserAgents());
    processor.setSocketBuffer(proto.getSocketBuffer());
    processor.setMaxSavePostSize(proto.getMaxSavePostSize());
    processor.setServer(proto.getServer());
    register(processor);
    return processor;
}
 
Example #15
Source File: Http11NioProcessor.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
protected void setCometTimeouts(SocketWrapper<NioChannel> socketWrapper) {
    // Comet support
    SelectionKey key = socketWrapper.getSocket().getIOChannel().keyFor(
            socketWrapper.getSocket().getPoller().getSelector());
    if (key != null) {
        NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment) key.attachment();
        if (attach != null)  {
            attach.setComet(comet);
            if (comet) {
                Integer comettimeout = (Integer) request.getAttribute(
                        org.apache.coyote.Constants.COMET_TIMEOUT_ATTR);
                if (comettimeout != null) {
                    attach.setTimeout(comettimeout.longValue());
                }
            }
        }
    }
}
 
Example #16
Source File: Http11NioProcessor.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean prepareSendfile(OutputFilter[] outputFilters) {
    String fileName = (String) request.getAttribute(
            org.apache.coyote.Constants.SENDFILE_FILENAME_ATTR);
    if (fileName != null) {
        // No entity body sent here
        outputBuffer.addActiveFilter(outputFilters[Constants.VOID_FILTER]);
        contentDelimitation = true;
        sendfileData = new NioEndpoint.SendfileData();
        sendfileData.fileName = fileName;
        sendfileData.pos = ((Long) request.getAttribute(
                org.apache.coyote.Constants.SENDFILE_FILE_START_ATTR)).longValue();
        sendfileData.length = ((Long) request.getAttribute(
                org.apache.coyote.Constants.SENDFILE_FILE_END_ATTR)).longValue() - sendfileData.pos;
        return true;
    }
    return false;
}
 
Example #17
Source File: Http11NioProcessor.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
protected void resetTimeouts() {
    final NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment)socketWrapper.getSocket().getAttachment();
    if (!getErrorState().isError() && attach != null &&
            asyncStateMachine.isAsyncDispatching()) {
        long soTimeout = endpoint.getSoTimeout();

        //reset the timeout
        if (keepAlive) {
            attach.setTimeout(keepAliveTimeout);
        } else {
            attach.setTimeout(soTimeout);
        }
    }
}
 
Example #18
Source File: InternalNioInputBuffer.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
protected void init(SocketWrapper<NioChannel> socketWrapper,
        AbstractEndpoint<NioChannel> endpoint) throws IOException {

    socket = socketWrapper.getSocket();
    socketReadBufferSize =
        socket.getBufHandler().getReadBuffer().capacity();

    int bufLength = headerBufferSize + socketReadBufferSize;
    if (buf == null || buf.length < bufLength) {
        buf = new byte[bufLength];
    }

    pool = ((NioEndpoint)endpoint).getSelectorPool();
}
 
Example #19
Source File: InternalNioOutputBuffer.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public void init(SocketWrapper<NioChannel> socketWrapper,
        AbstractEndpoint<NioChannel> endpoint) throws IOException {

    socket = socketWrapper.getSocket();
    pool = ((NioEndpoint)endpoint).getSelectorPool();
}
 
Example #20
Source File: InternalNioInputBuffer.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
protected void init(SocketWrapper<NioChannel> socketWrapper,
        AbstractEndpoint<NioChannel> endpoint) throws IOException {

    socket = socketWrapper.getSocket();
    socketReadBufferSize =
        socket.getBufHandler().getReadBuffer().capacity();

    int bufLength = headerBufferSize + socketReadBufferSize;
    if (buf == null || buf.length < bufLength) {
        buf = new byte[bufLength];
    }

    pool = ((NioEndpoint)endpoint).getSelectorPool();
}
 
Example #21
Source File: AjpNioProtocol.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public AjpNioProtocol() {
    endpoint = new NioEndpoint();
    cHandler = new AjpConnectionHandler(this);
    ((NioEndpoint) endpoint).setHandler(cHandler);
    setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
    setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
    setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);
    // AJP does not use Send File
    ((NioEndpoint) endpoint).setUseSendfile(false);
}
 
Example #22
Source File: AjpNioProtocol.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
protected AjpNioProcessor createProcessor() {
    AjpNioProcessor processor = new AjpNioProcessor(proto.packetSize, (NioEndpoint)proto.endpoint);
    processor.setAdapter(proto.adapter);
    processor.setTomcatAuthentication(proto.tomcatAuthentication);
    processor.setTomcatAuthorization(proto.getTomcatAuthorization());
    processor.setRequiredSecret(proto.requiredSecret);
    processor.setKeepAliveTimeout(proto.getKeepAliveTimeout());
    processor.setClientCertProvider(proto.getClientCertProvider());
    register(processor);
    return processor;
}
 
Example #23
Source File: AjpNioProcessor.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Send an action to the connector.
 *
 * @param actionCode Type of the action
 * @param param Action parameter
 */
@Override
@SuppressWarnings("incomplete-switch") // Other cases are handled by action()
protected void actionInternal(ActionCode actionCode, Object param) {

    switch (actionCode) {
    case ASYNC_COMPLETE: {
        if (asyncStateMachine.asyncComplete()) {
            ((NioEndpoint)endpoint).processSocket(this.socketWrapper.getSocket(),
                    SocketStatus.OPEN_READ, false);
        }
        break;
    }
    case ASYNC_SETTIMEOUT: {
        if (param == null) return;
        long timeout = ((Long)param).longValue();
        final KeyAttachment ka =
                (KeyAttachment)socketWrapper.getSocket().getAttachment();
        ka.setTimeout(timeout);
        break;
    }
    case ASYNC_DISPATCH: {
        if (asyncStateMachine.asyncDispatch()) {
            ((NioEndpoint)endpoint).processSocket(this.socketWrapper.getSocket(),
                    SocketStatus.OPEN_READ, true);
        }
        break;
    }
    }
}
 
Example #24
Source File: Http11NioProtocol.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public Http11NioProtocol() {
    endpoint=new NioEndpoint();
    cHandler = new Http11ConnectionHandler(this);
    ((NioEndpoint) endpoint).setHandler(cHandler);
    setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
    setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
    setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);
}
 
Example #25
Source File: NioServletInputStream.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
private int fillReadBuffer(boolean block) throws IOException {
    int nRead;
    if (block) {
        Selector selector = null;
        try {
            selector = pool.get();
        } catch ( IOException x ) {
            // Ignore
        }
        try {
            NioEndpoint.KeyAttachment att =
                    (NioEndpoint.KeyAttachment) channel.getAttachment();
            if (att == null) {
                throw new IOException("Key must be cancelled.");
            }
            nRead = pool.read(channel.getBufHandler().getReadBuffer(),
                    channel, selector, att.getTimeout());
        } catch (EOFException eof) {
            nRead = -1;
        } finally {
            if (selector != null) {
                pool.put(selector);
            }
        }
    } else {
        nRead = channel.read(channel.getBufHandler().getReadBuffer());
    }
    return nRead;
}
 
Example #26
Source File: NioServletOutputStream.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
private int doWriteInternal (boolean block, byte[] b, int off, int len)
        throws IOException {
    channel.getBufHandler().getWriteBuffer().clear();
    channel.getBufHandler().getWriteBuffer().put(b, off, len);
    channel.getBufHandler().getWriteBuffer().flip();

    int written = 0;
    NioEndpoint.KeyAttachment att =
            (NioEndpoint.KeyAttachment) channel.getAttachment();
    if (att == null) {
        throw new IOException("Key must be cancelled");
    }
    long writeTimeout = att.getWriteTimeout();
    Selector selector = null;
    try {
        selector = pool.get();
    } catch ( IOException x ) {
        //ignore
    }
    try {
        written = pool.write(channel.getBufHandler().getWriteBuffer(),
                channel, selector, writeTimeout, block);
    } finally {
        if (selector != null) {
            pool.put(selector);
        }
    }
    if (written < len) {
        channel.getPoller().add(channel, SelectionKey.OP_WRITE);
    }
    return written;
}
 
Example #27
Source File: UpgradeNioProcessor.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
private synchronized int writeToSocket(byte[] bytes, int off, int len)
        throws IOException {

    nioChannel.getBufHandler().getWriteBuffer().clear();
    nioChannel.getBufHandler().getWriteBuffer().put(bytes, off, len);
    nioChannel.getBufHandler().getWriteBuffer().flip();

    int written = 0;
    NioEndpoint.KeyAttachment att =
            (NioEndpoint.KeyAttachment) nioChannel.getAttachment();
    if (att == null) {
        throw new IOException("Key must be cancelled");
    }
    long writeTimeout = att.getTimeout();
    Selector selector = null;
    try {
        selector = pool.get();
    } catch ( IOException x ) {
        //ignore
    }
    try {
        written = pool.write(nioChannel.getBufHandler().getWriteBuffer(),
                nioChannel, selector, writeTimeout, true);
    } finally {
        if (selector != null) {
            pool.put(selector);
        }
    }
    return written;
}
 
Example #28
Source File: UpgradeNioProcessor.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
private int fillReadBuffer(boolean block) throws IOException {
    int nRead;
    if (block) {
        Selector selector = null;
        try {
            selector = pool.get();
        } catch ( IOException x ) {
            // Ignore
        }
        try {
            NioEndpoint.KeyAttachment att =
                    (NioEndpoint.KeyAttachment) nioChannel.getAttachment();
            if (att == null) {
                throw new IOException("Key must be cancelled.");
            }
            nRead = pool.read(nioChannel.getBufHandler().getReadBuffer(),
                    nioChannel, selector, att.getTimeout());
        } catch (EOFException eof) {
            nRead = -1;
        } finally {
            if (selector != null) {
                pool.put(selector);
            }
        }
    } else {
        nRead = nioChannel.read(nioChannel.getBufHandler().getReadBuffer());
    }
    return nRead;
}
 
Example #29
Source File: AjpNioProtocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public AjpNioProtocol() {
    endpoint = new NioEndpoint();
    cHandler = new AjpConnectionHandler(this);
    ((NioEndpoint) endpoint).setHandler(cHandler);
    setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
    setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
    setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);
    // AJP does not use Send File
    ((NioEndpoint) endpoint).setUseSendfile(false);
}
 
Example #30
Source File: AjpNioProcessor.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Send an action to the connector.
 *
 * @param actionCode Type of the action
 * @param param Action parameter
 */
@Override
@SuppressWarnings("incomplete-switch") // Other cases are handled by action()
protected void actionInternal(ActionCode actionCode, Object param) {

    switch (actionCode) {
    case ASYNC_COMPLETE: {
        if (asyncStateMachine.asyncComplete()) {
            ((NioEndpoint)endpoint).processSocket(this.socketWrapper.getSocket(),
                    SocketStatus.OPEN_READ, false);
        }
        break;
    }
    case ASYNC_SETTIMEOUT: {
        if (param == null) return;
        long timeout = ((Long)param).longValue();
        final KeyAttachment ka =
                (KeyAttachment)socketWrapper.getSocket().getAttachment();
        ka.setTimeout(timeout);
        break;
    }
    case ASYNC_DISPATCH: {
        if (asyncStateMachine.asyncDispatch()) {
            ((NioEndpoint)endpoint).processSocket(this.socketWrapper.getSocket(),
                    SocketStatus.OPEN_READ, true);
        }
        break;
    }
    }
}