tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1519423 - in /tomcat/trunk/java/org/apache/coyote/ajp: AbstractAjpProcessor.java AjpAprProcessor.java AjpNioProcessor.java AjpProcessor.java
Date Mon, 02 Sep 2013 12:56:44 GMT
Author: markt
Date: Mon Sep  2 12:56:43 2013
New Revision: 1519423

URL: http://svn.apache.org/r1519423
Log:
Refactoring. Pull up process method.

Modified:
    tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java
    tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
    tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java
    tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java?rev=1519423&r1=1519422&r2=1519423&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java Mon Sep  2 12:56:43
2013
@@ -576,6 +576,165 @@ public abstract class AbstractAjpProcess
     }
 
 
+    /**
+     * Process pipelined HTTP requests using the specified input and output
+     * streams.
+     *
+     * @throws IOException error during an I/O operation
+     */
+    @Override
+    public SocketState process(SocketWrapper<S> socket) throws IOException {
+
+        RequestInfo rp = request.getRequestProcessor();
+        rp.setStage(org.apache.coyote.Constants.STAGE_PARSE);
+
+        // Setting up the socket
+        this.socketWrapper = socket;
+
+        setupSocket(socket);
+
+        int soTimeout = endpoint.getSoTimeout();
+        boolean cping = false;
+
+        // Error flag
+        error = false;
+
+        boolean keptAlive = false;
+
+        while (!error && !endpoint.isPaused()) {
+            // Parsing the request header
+            try {
+                // Get first message of the request
+                if (!readMessage(requestHeaderMessage, !keptAlive)) {
+                    break;
+                }
+                // Set back timeout if keep alive timeout is enabled
+                if (keepAliveTimeout > 0) {
+                    setTimeout(socketWrapper, soTimeout);
+                }
+                // Check message type, process right away and break if
+                // not regular request processing
+                int type = requestHeaderMessage.getByte();
+                if (type == Constants.JK_AJP13_CPING_REQUEST) {
+                    if (endpoint.isPaused()) {
+                        recycle(true);
+                        break;
+                    }
+                    cping = true;
+                    try {
+                        output(pongMessageArray, 0, pongMessageArray.length);
+                    } catch (IOException e) {
+                        error = true;
+                    }
+                    recycle(false);
+                    continue;
+                } else if(type != Constants.JK_AJP13_FORWARD_REQUEST) {
+                    // Unexpected packet type. Unread body packets should have
+                    // been swallowed in finish().
+                    if (getLog().isDebugEnabled()) {
+                        getLog().debug("Unexpected message: " + type);
+                    }
+                    error = true;
+                    break;
+                }
+                keptAlive = true;
+                request.setStartTime(System.currentTimeMillis());
+            } catch (IOException e) {
+                error = true;
+                break;
+            } catch (Throwable t) {
+                ExceptionUtils.handleThrowable(t);
+                getLog().debug(sm.getString("ajpprocessor.header.error"), t);
+                // 400 - Bad Request
+                response.setStatus(400);
+                getAdapter().log(request, response, 0);
+                error = true;
+            }
+
+            if (!error) {
+                // Setting up filters, and parse some request headers
+                rp.setStage(org.apache.coyote.Constants.STAGE_PREPARE);
+                try {
+                    prepareRequest();
+                } catch (Throwable t) {
+                    ExceptionUtils.handleThrowable(t);
+                    getLog().debug(sm.getString("ajpprocessor.request.prepare"), t);
+                    // 400 - Internal Server Error
+                    response.setStatus(400);
+                    getAdapter().log(request, response, 0);
+                    error = true;
+                }
+            }
+
+            if (!error && !cping && endpoint.isPaused()) {
+                // 503 - Service unavailable
+                response.setStatus(503);
+                getAdapter().log(request, response, 0);
+                error = true;
+            }
+            cping = false;
+
+            // Process the request in the adapter
+            if (!error) {
+                try {
+                    rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE);
+                    getAdapter().service(request, response);
+                } catch (InterruptedIOException e) {
+                    error = true;
+                } catch (Throwable t) {
+                    ExceptionUtils.handleThrowable(t);
+                    getLog().error(sm.getString("ajpprocessor.request.process"), t);
+                    // 500 - Internal Server Error
+                    response.setStatus(500);
+                    getAdapter().log(request, response, 0);
+                    error = true;
+                }
+            }
+
+            if (isAsync() && !error) {
+                break;
+            }
+
+            // Finish the response if not done yet
+            if (!finished) {
+                try {
+                    finish();
+                } catch (Throwable t) {
+                    ExceptionUtils.handleThrowable(t);
+                    error = true;
+                }
+            }
+
+            // If there was an error, make sure the request is counted as
+            // and error, and update the statistics counter
+            if (error) {
+                response.setStatus(500);
+            }
+            request.updateCounters();
+
+            rp.setStage(org.apache.coyote.Constants.STAGE_KEEPALIVE);
+            // Set keep alive timeout if enabled
+            if (keepAliveTimeout > 0) {
+                setTimeout(socketWrapper, keepAliveTimeout);
+            }
+
+            recycle(false);
+        }
+
+        rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
+
+        if (!error && !endpoint.isPaused()) {
+            if (isAsync()) {
+                return SocketState.LONG;
+            } else {
+                return SocketState.OPEN;
+            }
+        } else {
+            return SocketState.CLOSED;
+        }
+    }
+
+
     @Override
     public void setSslSupport(SSLSupport sslSupport) {
         // Should never reach this code but in case we do...
@@ -639,6 +798,10 @@ public abstract class AbstractAjpProcess
     // Methods called by action()
     protected abstract void actionInternal(ActionCode actionCode, Object param);
 
+    // Methods called by process()
+    protected abstract void setupSocket(SocketWrapper<S> socketWrapper)
+            throws IOException;
+
     // Methods called by prepareResponse()
     protected abstract void output(byte[] src, int offset, int length)
             throws IOException;

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java?rev=1519423&r1=1519422&r2=1519423&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java Mon Sep  2 12:56:43 2013
@@ -17,18 +17,14 @@
 package org.apache.coyote.ajp;
 
 import java.io.IOException;
-import java.io.InterruptedIOException;
 import java.nio.ByteBuffer;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
 
 import org.apache.coyote.ActionCode;
-import org.apache.coyote.RequestInfo;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.jni.Socket;
-import org.apache.tomcat.util.ExceptionUtils;
-import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
 import org.apache.tomcat.util.net.AprEndpoint;
 import org.apache.tomcat.util.net.SocketStatus;
 import org.apache.tomcat.util.net.SocketWrapper;
@@ -87,173 +83,8 @@ public class AjpAprProcessor extends Abs
     protected final ByteBuffer outputBuffer;
 
 
-    // --------------------------------------------------------- Public Methods
-
-
-    /**
-     * Process pipelined HTTP requests using the specified input and output
-     * streams.
-     *
-     * @throws IOException error during an I/O operation
-     */
-    @Override
-    public SocketState process(SocketWrapper<Long> socket)
-        throws IOException {
-        RequestInfo rp = request.getRequestProcessor();
-        rp.setStage(org.apache.coyote.Constants.STAGE_PARSE);
-
-        // Setting up the socket
-        this.socketWrapper = socket;
-
-        long socketRef = socket.getSocket().longValue();
-        Socket.setrbb(socketRef, inputBuffer);
-        Socket.setsbb(socketRef, outputBuffer);
-
-        int soTimeout = endpoint.getSoTimeout();
-        boolean cping = false;
-
-        // Error flag
-        error = false;
-
-        boolean keptAlive = false;
-
-        while (!error && !endpoint.isPaused()) {
-            // Parsing the request header
-            try {
-                // Get first message of the request
-                if (!readMessage(requestHeaderMessage, !keptAlive)) {
-                    break;
-                }
-                // Set back timeout if keep alive timeout is enabled
-                if (keepAliveTimeout > 0) {
-                    setTimeout(socketWrapper, soTimeout);
-                }
-                // Check message type, process right away and break if
-                // not regular request processing
-                int type = requestHeaderMessage.getByte();
-                if (type == Constants.JK_AJP13_CPING_REQUEST) {
-                    if (endpoint.isPaused()) {
-                        recycle(true);
-                        break;
-                    }
-                    cping = true;
-                    try {
-                        output(pongMessageArray, 0, pongMessageArray.length);
-                    } catch (IOException e) {
-                        error = true;
-                    }
-                    recycle(false);
-                    continue;
-                } else if(type != Constants.JK_AJP13_FORWARD_REQUEST) {
-                    // Unexpected packet type. Unread body packets should have
-                    // been swallowed in finish().
-                    if (log.isDebugEnabled()) {
-                        log.debug("Unexpected message: " + type);
-                    }
-                    error = true;
-                    break;
-                }
-                keptAlive = true;
-                request.setStartTime(System.currentTimeMillis());
-            } catch (IOException e) {
-                error = true;
-                break;
-            } catch (Throwable t) {
-                ExceptionUtils.handleThrowable(t);
-                log.debug(sm.getString("ajpprocessor.header.error"), t);
-                // 400 - Bad Request
-                response.setStatus(400);
-                getAdapter().log(request, response, 0);
-                error = true;
-            }
-
-            if (!error) {
-                // Setting up filters, and parse some request headers
-                rp.setStage(org.apache.coyote.Constants.STAGE_PREPARE);
-                try {
-                    prepareRequest();
-                } catch (Throwable t) {
-                    ExceptionUtils.handleThrowable(t);
-                    log.debug(sm.getString("ajpprocessor.request.prepare"), t);
-                    // 400 - Internal Server Error
-                    response.setStatus(400);
-                    getAdapter().log(request, response, 0);
-                    error = true;
-                }
-            }
-
-            if (!error && !cping && endpoint.isPaused()) {
-                // 503 - Service unavailable
-                response.setStatus(503);
-                getAdapter().log(request, response, 0);
-                error = true;
-            }
-            cping = false;
-
-            // Process the request in the adapter
-            if (!error) {
-                try {
-                    rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE);
-                    getAdapter().service(request, response);
-                } catch (InterruptedIOException e) {
-                    error = true;
-                } catch (Throwable t) {
-                    ExceptionUtils.handleThrowable(t);
-                    log.error(sm.getString("ajpprocessor.request.process"), t);
-                    // 500 - Internal Server Error
-                    response.setStatus(500);
-                    getAdapter().log(request, response, 0);
-                    error = true;
-                }
-            }
-
-            if (isAsync() && !error) {
-                break;
-            }
-
-            // Finish the response if not done yet
-            if (!finished) {
-                try {
-                    finish();
-                } catch (Throwable t) {
-                    ExceptionUtils.handleThrowable(t);
-                    error = true;
-                }
-            }
-
-            // If there was an error, make sure the request is counted as
-            // and error, and update the statistics counter
-            if (error) {
-                response.setStatus(500);
-            }
-            request.updateCounters();
-
-            rp.setStage(org.apache.coyote.Constants.STAGE_KEEPALIVE);
-            // Set keep alive timeout if enabled
-            if (keepAliveTimeout > 0) {
-                setTimeout(socketWrapper, keepAliveTimeout);
-            }
-
-            recycle(false);
-        }
-
-        rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
-
-        if (!error && !endpoint.isPaused()) {
-            if (isAsync()) {
-                return SocketState.LONG;
-            } else {
-                return SocketState.OPEN;
-            }
-        } else {
-            return SocketState.CLOSED;
-        }
-    }
-
-
     // ----------------------------------------------------- ActionHook Methods
 
-
     /**
      * Send an action to the connector.
      *
@@ -284,6 +115,14 @@ public class AjpAprProcessor extends Abs
     // ------------------------------------------------------ Protected Methods
 
     @Override
+    protected void setupSocket(SocketWrapper<Long> socketWrapper) {
+        long socketRef = socketWrapper.getSocket().longValue();
+        Socket.setrbb(socketRef, inputBuffer);
+        Socket.setsbb(socketRef, outputBuffer);
+    }
+
+
+    @Override
     protected void setTimeout(SocketWrapper<Long> socketWrapper,
             int timeout) throws IOException {
         Socket.timeoutSet(

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java?rev=1519423&r1=1519422&r2=1519423&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java Mon Sep  2 12:56:43 2013
@@ -18,16 +18,12 @@ package org.apache.coyote.ajp;
 
 import java.io.EOFException;
 import java.io.IOException;
-import java.io.InterruptedIOException;
 import java.nio.ByteBuffer;
 import java.nio.channels.Selector;
 
 import org.apache.coyote.ActionCode;
-import org.apache.coyote.RequestInfo;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.util.ExceptionUtils;
-import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
 import org.apache.tomcat.util.net.NioChannel;
 import org.apache.tomcat.util.net.NioEndpoint;
 import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment;
@@ -72,169 +68,8 @@ public class AjpNioProcessor extends Abs
     protected final NioSelectorPool pool;
 
 
-    // --------------------------------------------------------- Public Methods
-
-
-    /**
-     * Process pipelined HTTP requests using the specified input and output
-     * streams.
-     *
-     * @throws IOException error during an I/O operation
-     */
-    @Override
-    public SocketState process(SocketWrapper<NioChannel> socket)
-        throws IOException {
-        RequestInfo rp = request.getRequestProcessor();
-        rp.setStage(org.apache.coyote.Constants.STAGE_PARSE);
-
-        // Setting up the socket
-        this.socketWrapper = socket;
-
-        int soTimeout = endpoint.getSoTimeout();
-        boolean cping = false;
-
-        // Error flag
-        error = false;
-
-        boolean keptAlive = false;
-
-        while (!error && !endpoint.isPaused()) {
-            // Parsing the request header
-            try {
-                // Get first message of the request
-                if (!readMessage(requestHeaderMessage, !keptAlive)) {
-                    break;
-                }
-                // Set back timeout if keep alive timeout is enabled
-                if (keepAliveTimeout > 0) {
-                    setTimeout(socketWrapper, soTimeout);
-                }
-                // Check message type, process right away and break if
-                // not regular request processing
-                int type = requestHeaderMessage.getByte();
-                if (type == Constants.JK_AJP13_CPING_REQUEST) {
-                    if (endpoint.isPaused()) {
-                        recycle(true);
-                        break;
-                    }
-                    cping = true;
-                    try {
-                        output(pongMessageArray, 0, pongMessageArray.length);
-                    } catch (IOException e) {
-                        error = true;
-                    }
-                    recycle(false);
-                    continue;
-                } else if(type != Constants.JK_AJP13_FORWARD_REQUEST) {
-                    // Unexpected packet type. Unread body packets should have
-                    // been swallowed in finish().
-                    if (log.isDebugEnabled()) {
-                        log.debug("Unexpected message: " + type);
-                    }
-                    error = true;
-                    break;
-                }
-                keptAlive = true;
-                request.setStartTime(System.currentTimeMillis());
-            } catch (IOException e) {
-                error = true;
-                break;
-            } catch (Throwable t) {
-                ExceptionUtils.handleThrowable(t);
-                log.debug(sm.getString("ajpprocessor.header.error"), t);
-                // 400 - Bad Request
-                response.setStatus(400);
-                getAdapter().log(request, response, 0);
-                error = true;
-            }
-
-            if (!error) {
-                // Setting up filters, and parse some request headers
-                rp.setStage(org.apache.coyote.Constants.STAGE_PREPARE);
-                try {
-                    prepareRequest();
-                } catch (Throwable t) {
-                    ExceptionUtils.handleThrowable(t);
-                    log.debug(sm.getString("ajpprocessor.request.prepare"), t);
-                    // 400 - Internal Server Error
-                    response.setStatus(400);
-                    getAdapter().log(request, response, 0);
-                    error = true;
-                }
-            }
-
-            if (!error && !cping && endpoint.isPaused()) {
-                // 503 - Service unavailable
-                response.setStatus(503);
-                getAdapter().log(request, response, 0);
-                error = true;
-            }
-            cping = false;
-
-            // Process the request in the adapter
-            if (!error) {
-                try {
-                    rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE);
-                    getAdapter().service(request, response);
-                } catch (InterruptedIOException e) {
-                    error = true;
-                } catch (Throwable t) {
-                    ExceptionUtils.handleThrowable(t);
-                    log.error(sm.getString("ajpprocessor.request.process"), t);
-                    // 500 - Internal Server Error
-                    response.setStatus(500);
-                    getAdapter().log(request, response, 0);
-                    error = true;
-                }
-            }
-
-            if (isAsync() && !error) {
-                break;
-            }
-
-            // Finish the response if not done yet
-            if (!finished) {
-                try {
-                    finish();
-                } catch (Throwable t) {
-                    ExceptionUtils.handleThrowable(t);
-                    error = true;
-                }
-            }
-
-            // If there was an error, make sure the request is counted as
-            // and error, and update the statistics counter
-            if (error) {
-                response.setStatus(500);
-            }
-            request.updateCounters();
-
-            rp.setStage(org.apache.coyote.Constants.STAGE_KEEPALIVE);
-            // Set keep alive timeout if enabled
-            if (keepAliveTimeout > 0) {
-                setTimeout(socketWrapper, keepAliveTimeout);
-            }
-
-            recycle(false);
-        }
-
-        rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
-
-        if (!error && !endpoint.isPaused()) {
-            if (isAsync()) {
-                return SocketState.LONG;
-            } else {
-                return SocketState.OPEN;
-            }
-        } else {
-            return SocketState.CLOSED;
-        }
-    }
-
-
     // ----------------------------------------------------- ActionHook Methods
 
-
     /**
      * Send an action to the connector.
      *
@@ -268,6 +103,13 @@ public class AjpNioProcessor extends Abs
     // ------------------------------------------------------ Protected Methods
 
     @Override
+    protected void setupSocket(SocketWrapper<NioChannel> socketWrapper)
+            throws IOException {
+        // NO-OP
+    }
+
+
+    @Override
     protected void setTimeout(SocketWrapper<NioChannel> socketWrapper,
             int timeout) throws IOException {
         socketWrapper.setTimeout(timeout);

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java?rev=1519423&r1=1519422&r2=1519423&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java Mon Sep  2 12:56:43 2013
@@ -18,16 +18,12 @@ package org.apache.coyote.ajp;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InterruptedIOException;
 import java.io.OutputStream;
 import java.net.Socket;
 
 import org.apache.coyote.ActionCode;
-import org.apache.coyote.RequestInfo;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.util.ExceptionUtils;
-import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
 import org.apache.tomcat.util.net.JIoEndpoint;
 import org.apache.tomcat.util.net.SocketStatus;
 import org.apache.tomcat.util.net.SocketWrapper;
@@ -83,165 +79,6 @@ public class AjpProcessor extends Abstra
 
     // --------------------------------------------------------- Public Methods
 
-
-    /**
-     * Process pipelined HTTP requests using the specified input and output
-     * streams.
-     *
-     * @throws IOException error during an I/O operation
-     */
-    @Override
-    public SocketState process(SocketWrapper<Socket> socket)
-        throws IOException {
-        RequestInfo rp = request.getRequestProcessor();
-        rp.setStage(org.apache.coyote.Constants.STAGE_PARSE);
-
-        // Setting up the socket
-        this.socketWrapper = socket;
-
-        input = socket.getSocket().getInputStream();
-        output = socket.getSocket().getOutputStream();
-
-        int soTimeout = endpoint.getSoTimeout();
-        boolean cping = false;
-
-        // Error flag
-        error = false;
-
-        boolean keptAlive = false;
-
-        while (!error && !endpoint.isPaused()) {
-            // Parsing the request header
-            try {
-                // Get first message of the request
-                if (!readMessage(requestHeaderMessage, !keptAlive)) {
-                    // This means a connection timeout
-                    break;
-                }
-                // Set back timeout if keep alive timeout is enabled
-                if (keepAliveTimeout > 0) {
-                    setTimeout(socketWrapper, soTimeout);
-                }
-                // Check message type, process right away and break if
-                // not regular request processing
-                int type = requestHeaderMessage.getByte();
-                if (type == Constants.JK_AJP13_CPING_REQUEST) {
-                    if (endpoint.isPaused()) {
-                        recycle(true);
-                        break;
-                    }
-                    cping = true;
-                    try {
-                        output.write(pongMessageArray);
-                    } catch (IOException e) {
-                        error = true;
-                    }
-                    continue;
-                } else if(type != Constants.JK_AJP13_FORWARD_REQUEST) {
-                    // Unexpected packet type. Unread body packets should have
-                    // been swallowed in finish().
-                    if (log.isDebugEnabled()) {
-                        log.debug("Unexpected message: " + type);
-                    }
-                    error = true;
-                    break;
-                }
-                keptAlive = true;
-                request.setStartTime(System.currentTimeMillis());
-            } catch (IOException e) {
-                error = true;
-                break;
-            } catch (Throwable t) {
-                ExceptionUtils.handleThrowable(t);
-                log.debug(sm.getString("ajpprocessor.header.error"), t);
-                // 400 - Bad Request
-                response.setStatus(400);
-                getAdapter().log(request, response, 0);
-                error = true;
-            }
-
-            if (!error) {
-                // Setting up filters, and parse some request headers
-                rp.setStage(org.apache.coyote.Constants.STAGE_PREPARE);
-                try {
-                    prepareRequest();
-                } catch (Throwable t) {
-                    ExceptionUtils.handleThrowable(t);
-                    log.debug(sm.getString("ajpprocessor.request.prepare"), t);
-                    // 400 - Internal Server Error
-                    response.setStatus(400);
-                    getAdapter().log(request, response, 0);
-                    error = true;
-                }
-            }
-
-            if (!error && !cping && endpoint.isPaused()) {
-                // 503 - Service unavailable
-                response.setStatus(503);
-                getAdapter().log(request, response, 0);
-                error = true;
-            }
-            cping = false;
-
-            // Process the request in the adapter
-            if (!error) {
-                try {
-                    rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE);
-                    getAdapter().service(request, response);
-                } catch (InterruptedIOException e) {
-                    error = true;
-                } catch (Throwable t) {
-                    ExceptionUtils.handleThrowable(t);
-                    log.error(sm.getString("ajpprocessor.request.process"), t);
-                    // 500 - Internal Server Error
-                    response.setStatus(500);
-                    getAdapter().log(request, response, 0);
-                    error = true;
-                }
-            }
-
-            if (isAsync() && !error) {
-                break;
-            }
-
-            // Finish the response if not done yet
-            if (!finished) {
-                try {
-                    finish();
-                } catch (Throwable t) {
-                    ExceptionUtils.handleThrowable(t);
-                    error = true;
-                }
-            }
-
-            // If there was an error, make sure the request is counted as
-            // and error, and update the statistics counter
-            if (error) {
-                response.setStatus(500);
-            }
-            request.updateCounters();
-
-            rp.setStage(org.apache.coyote.Constants.STAGE_KEEPALIVE);
-            // Set keep alive timeout if enabled
-            if (keepAliveTimeout > 0) {
-                setTimeout(socketWrapper, keepAliveTimeout);
-            }
-
-            recycle(false);
-        }
-
-        rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
-
-        if (isAsync() && !error && !endpoint.isPaused()) {
-            return SocketState.LONG;
-        } else {
-            input = null;
-            output = null;
-            return SocketState.CLOSED;
-        }
-
-    }
-
     @Override
     public void recycle(boolean socketClosing) {
         super.recycle(socketClosing);
@@ -285,6 +122,14 @@ public class AjpProcessor extends Abstra
     // ------------------------------------------------------ Protected Methods
 
     @Override
+    protected void setupSocket(SocketWrapper<Socket> socketWrapper)
+            throws IOException {
+        input = socketWrapper.getSocket().getInputStream();
+        output = socketWrapper.getSocket().getOutputStream();
+    }
+
+
+    @Override
     protected void setTimeout(SocketWrapper<Socket> socketWrapper,
             int timeout) throws IOException {
         socketWrapper.getSocket().setSoTimeout(timeout);



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


Mime
View raw message