You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2014/09/19 02:30:15 UTC

[Bug 56995] Errors from servlet writer flush() causing threads in BLOCK state

https://issues.apache.org/bugzilla/show_bug.cgi?id=56995

--- Comment #1 from charlie <ch...@yahoo.com> ---
locks the socket here.

http://svn.apache.org/repos/asf/tomcat/tc7.0.x/tags/TOMCAT_7_0_55/java/org/apache/tomcat/util/net/JIoEndpoint.java

        @Override
        public void run() {
            boolean launch = false;
            synchronized (socket) {
                try {
                    SocketState state = SocketState.OPEN;

client tries to flush but throws IOException

http://svn.apache.org/repos/asf/tomcat/tc7.0.x/tags/TOMCAT_7_0_55/java/org/apache/coyote/http11/AbstractHttp11Processor.java

       case CLIENT_FLUSH: {
            try {
                getOutputBuffer().flush();
            } catch (IOException e) {
                setErrorState(ErrorState.CLOSE_NOW, e);
                response.setErrorException(e);
            }
            break;
        }

Calls setErrorState and which then calls processSocketAsync


  /**
     * Update the current error state to the new error state if the new error
     * state is more severe than the current error state.
     */
    protected void setErrorState(ErrorState errorState, Throwable t) {
        boolean blockIo = this.errorState.isIoAllowed() &&
!errorState.isIoAllowed();
        this.errorState = this.errorState.getMostSevere(errorState);
        if (blockIo && !ContainerThreadMarker.isContainerThread()) {
            // The error occurred on a non-container thread which means not all
            // of the necessary clean-up will have been completed. Dispatch to
            // a container thread to do the clean-up. Need to do it this way to
            // ensure that all the necessary clean-up is performed.
            if (response.getStatus() < 400) {
                response.setStatus(500);
            }
           
getLog().info(sm.getString("abstractProcessor.nonContainerThreadError"), t);
            getEndpoint().processSocketAsync(socketWrapper,
SocketStatus.CLOSE_NOW);
        }
    }


Tries to hold the same lock here causing threads to be in bad BLOCKED states
which eventually make all available threads to hang.

http://svn.apache.org/repos/asf/tomcat/tc7.0.x/tags/TOMCAT_7_0_55/java/org/apache/tomcat/util/net/JIoEndpoint.java

    @Override
    public void processSocketAsync(SocketWrapper<Socket> socket,
            SocketStatus status) {
        try {
            synchronized (socket) {
                if (waitingRequests.remove(socket)) {

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org