You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/08/13 23:47:36 UTC

svn commit: r1513665 - in /tomcat/trunk/java/org/apache/tomcat/util/net: AprEndpoint.java res/LocalStrings.properties

Author: markt
Date: Tue Aug 13 21:47:36 2013
New Revision: 1513665

URL: http://svn.apache.org/r1513665
Log:
Poller may return an error value with or without a value that matches a registered event.
Use i18n for debug messages.
Make debug messages consistent.
Add new debug message to show what events poller returned.
Improvements while working on a fix for BZ 55381.

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
    tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties

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=1513665&r1=1513664&r2=1513665&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Tue Aug 13 21:47:36 2013
@@ -795,7 +795,8 @@ public class AprEndpoint extends Abstrac
             // During shutdown, executor may be null - avoid NPE
             if (running) {
                 if (log.isDebugEnabled()) {
-                    log.debug("processSocketWithOptions(long): " + socket);
+                    log.debug(sm.getString("endpoint.debug.socket",
+                            Long.valueOf(socket)));
                 }
                 AprSocketWrapper wrapper =
                         new AprSocketWrapper(Long.valueOf(socket));
@@ -912,7 +913,8 @@ public class AprEndpoint extends Abstrac
 
     private void destroySocket(long socket, boolean doIt) {
         if (log.isDebugEnabled()) {
-            String msg = "destroySocket(long,boolean): " + socket + " " + doIt;
+            String msg = sm.getString("endpoint.debug.destroySocket",
+                    Long.valueOf(socket), Boolean.valueOf(doIt));
             if (log.isTraceEnabled()) {
                 log.trace(msg, new Exception());
             } else {
@@ -1430,8 +1432,9 @@ public class AprEndpoint extends Abstrac
 
         private void add(long socket, int timeout, int flags) {
             if (log.isDebugEnabled()) {
-                String msg = "Poller.add(long,int,int) " + socket + " " +
-                        timeout + " " + flags;
+                String msg = sm.getString("endpoint.debug.pollerAdd",
+                        Long.valueOf(socket), Integer.valueOf(timeout),
+                        Integer.valueOf(flags));
                 if (log.isTraceEnabled()) {
                     log.trace(msg, new Exception());
                 } else {
@@ -1516,7 +1519,8 @@ public class AprEndpoint extends Abstrac
             long socket = timeouts.check(date);
             while (socket != 0) {
                 if (log.isDebugEnabled()) {
-                    log.debug("Poller maintain() timing out socket: " + socket);
+                    log.debug(sm.getString("endpoint.debug.socketTimeout",
+                            Long.valueOf(socket)));
                 }
                 removeFromPoller(socket);
                 boolean comet = connections.get(
@@ -1599,8 +1603,9 @@ public class AprEndpoint extends Abstrac
                         SocketInfo info = localAddList.get();
                         while (info != null) {
                             if (log.isDebugEnabled()) {
-                                log.debug("Poller run() adding socket: " +
-                                        info.socket);
+                                log.debug(sm.getString(
+                                        "endpoint.debug.pollerAddDo",
+                                        Long.valueOf(info.socket)));
                             }
                             timeouts.remove(info.socket);
                             AprSocketWrapper wrapper = connections.get(
@@ -1657,6 +1662,12 @@ public class AprEndpoint extends Abstrac
                                 timeouts.remove(desc[n*2+1]);
                                 AprSocketWrapper wrapper = connections.get(
                                         Long.valueOf(desc[n*2+1]));
+                                if (getLog().isDebugEnabled()) {
+                                    log.debug(sm.getString(
+                                            "endpoint.debug.pollerProcess",
+                                            Long.valueOf(desc[n*2+1]),
+                                            Long.valueOf(desc[n*2])));
+                                }
                                 wrapper.pollerFlags = wrapper.pollerFlags & ~((int) desc[n*2]);
                                 // Check for failed sockets and hand this socket off to a worker
                                 if (wrapper.isComet()) {
@@ -1700,19 +1711,22 @@ public class AprEndpoint extends Abstrac
                                     if (wrapper.isAsync()) {
                                         // Must be using non-blocking IO for the socket to be in the
                                         // poller during async processing. Need to trigger error
-                                        // handling. Poller will return error codes plus the flags it
-                                        // was waiting for. We could return ASYNC_[WRITE|READ]_ERROR
-                                        // error here but if we do, there will be no exception
-                                        // associated with the error. By signalling read/write is
-                                        // possible, a read/write will be attempted, fail and that
-                                        // will trigger an exception
-                                        if ((desc[n*2] & Poll.APR_POLLIN) == Poll.APR_POLLIN) {
+                                        // handling. Poller may return error codes plus the flags it
+                                        // was waiting for or it may just return an error code. We
+                                        // could return ASYNC_[WRITE|READ]_ERROR here but if we do,
+                                        // there will be no exception associated with the error in
+                                        // application code. By signalling read/write is possible, a
+                                        // read/write will be attempted, fail and that will trigger
+                                        // an exception the application will see.
+                                        if ((desc[n*2] & Poll.APR_POLLIN) == Poll.APR_POLLIN ||
+                                                (wrapper.pollerFlags & Poll.APR_POLLIN) == Poll.APR_POLLIN) {
                                             // Must be doing a non-blocking read
                                             if (!processSocket(desc[n*2+1], SocketStatus.OPEN_READ)) {
                                                 // Close socket and clear pool
                                                 destroySocket(desc[n*2+1]);
                                             }
-                                        } else if ((desc[n*2] & Poll.APR_POLLOUT) == Poll.APR_POLLOUT) {
+                                        } else if ((desc[n*2] & Poll.APR_POLLOUT) == Poll.APR_POLLOUT ||
+                                                (wrapper.pollerFlags & Poll.APR_POLLOUT) == Poll.APR_POLLOUT) {
                                             // Must be doing an non-blocking write write
                                             if (!processSocket(desc[n*2+1], SocketStatus.OPEN_WRITE)) {
                                                 // Close socket and clear pool

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties?rev=1513665&r1=1513664&r2=1513665&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties Tue Aug 13 21:47:36 2013
@@ -23,7 +23,13 @@ endpoint.warn.noHonorCipherOrder='Honor 
 endpoint.warn.noInsecureReneg=Secure re-negotiation is not supported by the SSL library {0}
 endpoint.warn.unlockAcceptorFailed=Acceptor thread [{0}] failed to unlock. Forcing hard socket shutdown.
 endpoint.debug.channelCloseFail=Failed to close channel
+endpoint.debug.destroySocket=socket [{0}], doIt [{1}]
+endpoint.debug.pollerAdd=socket [{0}], timeout [{1}], flags [{2}]
+endpoint.debug.pollerAddDo=socket [{0}]
+endpoint.debug.pollerProcess=Processing socket [{0}] for event(s) [{1}]
+endpoint.debug.socket=socket [{0}]
 endpoint.debug.socketCloseFail=Failed to close socket
+endpoint.debug.socketTimeout=Timing out [{0}
 endpoint.debug.unlock=Caught exception trying to unlock accept on port {0}
 endpoint.init.bind=Socket bind failed: [{0}] {1}
 endpoint.init.listen=Socket listen failed: [{0}] {1}



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