Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F3571E94F for ; Wed, 16 Jan 2013 21:53:19 +0000 (UTC) Received: (qmail 95193 invoked by uid 500); 16 Jan 2013 21:53:19 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 95143 invoked by uid 500); 16 Jan 2013 21:53:19 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 95134 invoked by uid 99); 16 Jan 2013 21:53:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Jan 2013 21:53:19 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Jan 2013 21:53:17 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id BBF3B2388A56 for ; Wed, 16 Jan 2013 21:52:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1434428 - /tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Date: Wed, 16 Jan 2013 21:52:58 -0000 To: dev@tomcat.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130116215258.BBF3B2388A56@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: markt Date: Wed Jan 16 21:52:58 2013 New Revision: 1434428 URL: http://svn.apache.org/viewvc?rev=1434428&view=rev Log: APR/native refactoring - Remove SocketEventProcessor - Align code with JIO connector (with a view to further refactoring) Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=1434428&r1=1434427&r2=1434428&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Wed Jan 16 21:52:58 2013 @@ -825,7 +825,7 @@ public class AprEndpoint extends Abstrac * Process given socket. Called in non-comet mode, typically keep alive * or upgraded protocol. */ - protected boolean processSocket(long socket) { + public boolean processSocket(long socket, SocketStatus status) { try { Executor executor = getExecutor(); if (executor == null) { @@ -834,7 +834,7 @@ public class AprEndpoint extends Abstrac } else { SocketWrapper wrapper = new SocketWrapper<>(Long.valueOf(socket)); - executor.execute(new SocketProcessor(wrapper, null)); + executor.execute(new SocketProcessor(wrapper, status)); } } catch (RejectedExecutionException x) { log.warn("Socket processing request was rejected for:"+socket,x); @@ -850,33 +850,6 @@ public class AprEndpoint extends Abstrac } - /** - * Process given socket for an event. - */ - public boolean processSocket(long socket, SocketStatus status) { - try { - Executor executor = getExecutor(); - if (executor == null) { - log.warn(sm.getString("endpoint.warn.noExector", - Long.valueOf(socket), status)); - } else { - SocketWrapper wrapper = - new SocketWrapper<>(Long.valueOf(socket)); - executor.execute(new SocketEventProcessor(wrapper, status)); - } - } catch (RejectedExecutionException x) { - log.warn("Socket processing request was rejected for:"+socket,x); - return false; - } catch (Throwable t) { - ExceptionUtils.handleThrowable(t); - // This means we got an OOM or similar creating a thread, or that - // the pool and its queue are full - log.error(sm.getString("endpoint.process.fail"), t); - return false; - } - return true; - } - public boolean processSocketAsync(SocketWrapper socket, SocketStatus status) { try { @@ -1702,7 +1675,7 @@ public class AprEndpoint extends Abstrac // Close socket and clear pool destroySocket(desc[n*2+1]); } else if ((desc[n*2] & Poll.APR_POLLIN) == Poll.APR_POLLIN) { - if (!processSocket(desc[n*2+1])) { + if (!processSocket(desc[n*2+1], SocketStatus.OPEN_READ)) { // Close socket and clear pool destroySocket(desc[n*2+1]); } @@ -2175,6 +2148,10 @@ public class AprEndpoint extends Abstrac public SocketProcessor(SocketWrapper socket, SocketStatus status) { this.socket = socket; + if (status == null) { + // Should never happen + throw new NullPointerException(); + } this.status = status; } @@ -2182,12 +2159,7 @@ public class AprEndpoint extends Abstrac public void run() { synchronized (socket) { // Process the request from this socket - SocketState state = SocketState.OPEN; - if (status == null) { - state = handler.process(socket,SocketStatus.OPEN_READ); - } else { - state = handler.process(socket, status); - } + SocketState state = handler.process(socket, status); if (state == Handler.SocketState.CLOSED) { // Close socket and pool destroySocket(socket.getSocket().longValue()); @@ -2199,7 +2171,8 @@ public class AprEndpoint extends Abstrac } } else if (state == Handler.SocketState.ASYNC_END) { socket.access(); - SocketProcessor proc = new SocketProcessor(socket, SocketStatus.OPEN_READ); + SocketProcessor proc = new SocketProcessor(socket, + SocketStatus.OPEN_READ); getExecutor().execute(proc); } } @@ -2207,38 +2180,6 @@ public class AprEndpoint extends Abstrac } - // --------------------------------------- SocketEventProcessor Inner Class - - - /** - * This class is the equivalent of the Worker, but will simply use in an - * external Executor thread pool. - */ - protected class SocketEventProcessor implements Runnable { - - protected SocketWrapper socket = null; - protected SocketStatus status = null; - - public SocketEventProcessor(SocketWrapper socket, - SocketStatus status) { - this.socket = socket; - this.status = status; - } - - @Override - public void run() { - synchronized (socket) { - // Process the request from this socket - Handler.SocketState state = handler.process(socket, status); - if (state == Handler.SocketState.CLOSED) { - // Close socket and pool - destroySocket(socket.getSocket().longValue()); - socket = null; - } - } - } - } - private static class PrivilegedSetTccl implements PrivilegedAction { private ClassLoader cl; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org