Java Code Examples for org.apache.coyote.Processor#recycle()

The following examples show how to use org.apache.coyote.Processor#recycle() . 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 Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Expected to be used by the Poller to release resources on socket
 * close, errors etc.
 */
@Override
public void release(SocketChannel socket) {
    if (log.isDebugEnabled()) 
        log.debug("Iterating through our connections to release a socket channel:"+socket);
    boolean released = false;
    Iterator<java.util.Map.Entry<NioChannel, Processor<NioChannel>>> it = connections.entrySet().iterator();
    while (it.hasNext()) {
        java.util.Map.Entry<NioChannel, Processor<NioChannel>> entry = it.next();
        if (entry.getKey().getIOChannel()==socket) {
            it.remove();
            Processor<NioChannel> result = entry.getValue();
            result.recycle(true);
            unregister(result);
            released = true;
            break;
        }
    }
    if (log.isDebugEnabled()) 
        log.debug("Done iterating through our connections to release a socket channel:"+socket +" released:"+released);
}
 
Example 2
Source File: Http11NioProtocol.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Expected to be used by the Poller to release resources on socket
 * close, errors etc.
 */
@Override
public void release(SocketChannel socket) {
    if (log.isDebugEnabled())
        log.debug("Iterating through our connections to release a socket channel:"+socket);
    boolean released = false;
    Iterator<java.util.Map.Entry<NioChannel, Processor<NioChannel>>> it = connections.entrySet().iterator();
    while (it.hasNext()) {
        java.util.Map.Entry<NioChannel, Processor<NioChannel>> entry = it.next();
        if (entry.getKey().getIOChannel()==socket) {
            it.remove();
            Processor<NioChannel> result = entry.getValue();
            result.recycle(true);
            unregister(result);
            released = true;
            break;
        }
    }
    if (log.isDebugEnabled())
        log.debug("Done iterating through our connections to release a socket channel:"+socket +" released:"+released);
}
 
Example 3
Source File: Http11NioProtocol.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Expected to be used by the Poller to release resources on socket
 * close, errors etc.
 */
@Override
public void release(SocketChannel socket) {
    if (log.isDebugEnabled())
        log.debug("Iterating through our connections to release a socket channel:"+socket);
    boolean released = false;
    Iterator<java.util.Map.Entry<NioChannel, Processor<NioChannel>>> it = connections.entrySet().iterator();
    while (it.hasNext()) {
        java.util.Map.Entry<NioChannel, Processor<NioChannel>> entry = it.next();
        if (entry.getKey().getIOChannel()==socket) {
            it.remove();
            Processor<NioChannel> result = entry.getValue();
            result.recycle(true);
            unregister(result);
            released = true;
            break;
        }
    }
    if (log.isDebugEnabled())
        log.debug("Done iterating through our connections to release a socket channel:"+socket +" released:"+released);
}
 
Example 4
Source File: AjpNioProtocol.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Expected to be used by the Poller to release resources on socket
 * close, errors etc.
 */
@Override
public void release(SocketChannel socket) {
    if (log.isDebugEnabled()) 
        log.debug("Iterating through our connections to release a socket channel:"+socket);
    boolean released = false;
    Iterator<java.util.Map.Entry<NioChannel, Processor<NioChannel>>> it = connections.entrySet().iterator();
    while (it.hasNext()) {
        java.util.Map.Entry<NioChannel, Processor<NioChannel>> entry = it.next();
        if (entry.getKey().getIOChannel()==socket) {
            it.remove();
            Processor<NioChannel> result = entry.getValue();
            result.recycle(true);
            unregister(result);
            released = true;
            break;
        }
    }
    if (log.isDebugEnabled()) 
        log.debug("Done iterating through our connections to release a socket channel:"+socket +" released:"+released);
}
 
Example 5
Source File: Http11AprProtocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Expected to be used by the handler once the processor is no longer
 * required.
 * 
 * @param socket
 * @param processor
 * @param isSocketClosing   Not used in HTTP
 * @param addToPoller
 */
@Override
public void release(SocketWrapper<Long> socket,
        Processor<Long> processor, boolean isSocketClosing,
        boolean addToPoller) {
    processor.recycle(isSocketClosing);
    recycledProcessors.offer(processor);
    if (addToPoller && proto.endpoint.isRunning()) {
        ((AprEndpoint)proto.endpoint).getPoller().add(
                socket.getSocket().longValue(),
                proto.endpoint.getKeepAliveTimeout(), true, false);
    }
}
 
Example 6
Source File: Http11NioProtocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Expected to be used by the handler once the processor is no longer
 * required.
 *
 * @param socket
 * @param processor
 * @param isSocketClosing   Not used in HTTP
 * @param addToPoller
 */
@Override
public void release(SocketWrapper<NioChannel> socket,
        Processor<NioChannel> processor, boolean isSocketClosing,
        boolean addToPoller) {
    processor.recycle(isSocketClosing);
    recycledProcessors.offer(processor);
    if (addToPoller) {
        // The only time this method is called with addToPoller == true
        // is when the socket is in keep-alive so set the appropriate
        // timeout.
        socket.setTimeout(getProtocol().getKeepAliveTimeout());
        socket.getSocket().getPoller().add(socket.getSocket());
    }
}
 
Example 7
Source File: Http11NioProtocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Expected to be used by the Poller to release resources on socket
 * close, errors etc.
 */
@Override
public void release(SocketWrapper<NioChannel> socket) {
    Processor<NioChannel> processor =
        connections.remove(socket.getSocket());
    if (processor != null) {
        processor.recycle(true);
        if (!processor.isUpgrade()) {
            recycledProcessors.offer(processor);
        }
    }
}
 
Example 8
Source File: AjpAprProtocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Expected to be used by the handler once the processor is no longer
 * required.
 */
@Override
public void release(SocketWrapper<Long> socket,
        Processor<Long> processor, boolean isSocketClosing,
        boolean addToPoller) {
    processor.recycle(isSocketClosing);
    recycledProcessors.offer(processor);
    if (addToPoller) {
        ((AprEndpoint)proto.endpoint).getPoller().add(
                socket.getSocket().longValue(),
                proto.endpoint.getKeepAliveTimeout(),
                true, false);
    }
}
 
Example 9
Source File: AjpNioProtocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Expected to be used by the handler once the processor is no longer
 * required.
 */
@Override
public void release(SocketWrapper<NioChannel> socket,
        Processor<NioChannel> processor, boolean isSocketClosing,
        boolean addToPoller) {
    processor.recycle(isSocketClosing);
    recycledProcessors.offer(processor);
    if (addToPoller) {
        // The only time this method is called with addToPoller == true
        // is when the socket is in keep-alive so set the appropriate
        // timeout.
        socket.setTimeout(getProtocol().getKeepAliveTimeout());
        socket.getSocket().getPoller().add(socket.getSocket());
    }
}
 
Example 10
Source File: AjpNioProtocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Expected to be used by the Poller to release resources on socket
 * close, errors etc.
 */
@Override
public void release(SocketWrapper<NioChannel> socket) {
    Processor<NioChannel> processor =
            connections.remove(socket.getSocket());
    if (processor != null) {
        processor.recycle(true);
        recycledProcessors.offer(processor);
    }
}
 
Example 11
Source File: Http11AprProtocol.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Expected to be used by the handler once the processor is no longer
 * required.
 * 
 * @param socket
 * @param processor
 * @param isSocketClosing   Not used in HTTP
 * @param addToPoller
 */
@Override
public void release(SocketWrapper<Long> socket,
        Processor<Long> processor, boolean isSocketClosing,
        boolean addToPoller) {
    processor.recycle(isSocketClosing);
    recycledProcessors.offer(processor);
    if (addToPoller && proto.endpoint.isRunning()) {
        ((AprEndpoint)proto.endpoint).getPoller().add(
                socket.getSocket().longValue(),
                proto.endpoint.getKeepAliveTimeout(), true, false);
    }
}
 
Example 12
Source File: Http11NioProtocol.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Expected to be used by the handler once the processor is no longer
 * required.
 *
 * @param socket
 * @param processor
 * @param isSocketClosing   Not used in HTTP
 * @param addToPoller
 */
@Override
public void release(SocketWrapper<NioChannel> socket,
        Processor<NioChannel> processor, boolean isSocketClosing,
        boolean addToPoller) {
    processor.recycle(isSocketClosing);
    recycledProcessors.offer(processor);
    if (addToPoller) {
        // The only time this method is called with addToPoller == true
        // is when the socket is in keep-alive so set the appropriate
        // timeout.
        socket.setTimeout(getProtocol().getKeepAliveTimeout());
        socket.getSocket().getPoller().add(socket.getSocket());
    }
}
 
Example 13
Source File: Http11NioProtocol.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Expected to be used by the Poller to release resources on socket
 * close, errors etc.
 */
@Override
public void release(SocketWrapper<NioChannel> socket) {
    Processor<NioChannel> processor =
        connections.remove(socket.getSocket());
    if (processor != null) {
        processor.recycle(true);
        recycledProcessors.offer(processor);
    }
}
 
Example 14
Source File: AjpAprProtocol.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Expected to be used by the handler once the processor is no longer
 * required.
 */
@Override
public void release(SocketWrapper<Long> socket,
        Processor<Long> processor, boolean isSocketClosing,
        boolean addToPoller) {
    processor.recycle(isSocketClosing);
    recycledProcessors.offer(processor);
    if (addToPoller) {
        ((AprEndpoint)proto.endpoint).getPoller().add(
                socket.getSocket().longValue(),
                proto.endpoint.getKeepAliveTimeout(),
                true, false);
    }
}
 
Example 15
Source File: AjpNioProtocol.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Expected to be used by the handler once the processor is no longer
 * required.
 */
@Override
public void release(SocketWrapper<NioChannel> socket,
        Processor<NioChannel> processor, boolean isSocketClosing,
        boolean addToPoller) {
    processor.recycle(isSocketClosing);
    recycledProcessors.offer(processor);
    if (addToPoller) {
        // The only time this method is called with addToPoller == true
        // is when the socket is in keep-alive so set the appropriate
        // timeout.
        socket.setTimeout(getProtocol().getKeepAliveTimeout());
        socket.getSocket().getPoller().add(socket.getSocket());
    }
}
 
Example 16
Source File: AjpNioProtocol.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Expected to be used by the Poller to release resources on socket
 * close, errors etc.
 */
@Override
public void release(SocketWrapper<NioChannel> socket) {
    Processor<NioChannel> processor =
            connections.remove(socket.getSocket());
    if (processor != null) {
        processor.recycle(true);
        recycledProcessors.offer(processor);
    }
}
 
Example 17
Source File: AjpProtocol.java    From tomcatsrc with Apache License 2.0 3 votes vote down vote up
/**
 * Expected to be used by the handler once the processor is no longer
 * required.
 * 
 * @param socket            Ignored for BIO
 * @param processor
 * @param isSocketClosing
 * @param addToPoller       Ignored for BIO
 */
@Override
public void release(SocketWrapper<Socket> socket,
        Processor<Socket> processor, boolean isSocketClosing,
        boolean addToPoller) {
    processor.recycle(isSocketClosing);
    recycledProcessors.offer(processor);
}
 
Example 18
Source File: Http11Protocol.java    From Tomcat7.0.67 with Apache License 2.0 3 votes vote down vote up
/**
 * Expected to be used by the handler once the processor is no longer
 * required.
 * 
 * @param socket            Not used in BIO
 * @param processor
 * @param isSocketClosing   Not used in HTTP
 * @param addToPoller       Not used in BIO
 */
@Override
public void release(SocketWrapper<Socket> socket,
        Processor<Socket> processor, boolean isSocketClosing,
        boolean addToPoller) {
    processor.recycle(isSocketClosing);
    recycledProcessors.offer(processor);
}
 
Example 19
Source File: Http11Protocol.java    From tomcatsrc with Apache License 2.0 3 votes vote down vote up
/**
 * Expected to be used by the handler once the processor is no longer
 * required.
 * 
 * @param socket            Not used in BIO
 * @param processor
 * @param isSocketClosing   Not used in HTTP
 * @param addToPoller       Not used in BIO
 */
@Override
public void release(SocketWrapper<Socket> socket,
        Processor<Socket> processor, boolean isSocketClosing,
        boolean addToPoller) {
    processor.recycle(isSocketClosing);
    recycledProcessors.offer(processor);
}
 
Example 20
Source File: AjpProtocol.java    From Tomcat7.0.67 with Apache License 2.0 3 votes vote down vote up
/**
 * Expected to be used by the handler once the processor is no longer
 * required.
 * 
 * @param socket            Ignored for BIO
 * @param processor
 * @param isSocketClosing
 * @param addToPoller       Ignored for BIO
 */
@Override
public void release(SocketWrapper<Socket> socket,
        Processor<Socket> processor, boolean isSocketClosing,
        boolean addToPoller) {
    processor.recycle(isSocketClosing);
    recycledProcessors.offer(processor);
}