Author: markt
Date: Tue Oct 16 22:19:09 2012
New Revision: 1399023

URL: http://svn.apache.org/viewvc?rev=1399023&view=rev
Log:
Expose the option to register an APR Socket for write as well as read events. 
This is currently unused but will be required when the (as yet unwritten) 
updated WebSocket implementation is back-ported from trunk as the JSR-356 API 
is non-blocking.

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java
    tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1399022

Modified: tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java?rev=1399023&r1=1399022&r2=1399023&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java 
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java Tue Oct 
16 22:19:09 2012
@@ -135,7 +135,8 @@ public class AjpAprProtocol extends Abst
             if (addToPoller) {
                 ((AprEndpoint)proto.endpoint).getPoller().add(
                         socket.getSocket().longValue(),
-                        proto.endpoint.getKeepAliveTimeout());
+                        proto.endpoint.getKeepAliveTimeout(),
+                        AprEndpoint.Poller.FLAGS_READ);
             }
         }
 

Modified: 
tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java?rev=1399023&r1=1399022&r2=1399023&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java 
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java 
Tue Oct 16 22:19:09 2012
@@ -243,7 +243,8 @@ public class Http11AprProtocol extends A
             if (addToPoller && proto.endpoint.isRunning()) {
                 ((AprEndpoint)proto.endpoint).getPoller().add(
                         socket.getSocket().longValue(),
-                        proto.endpoint.getKeepAliveTimeout());
+                        proto.endpoint.getKeepAliveTimeout(),
+                        AprEndpoint.Poller.FLAGS_READ);
             }
         }
 
@@ -266,7 +267,8 @@ public class Http11AprProtocol extends A
                 if (proto.endpoint.isRunning()) {
                     ((AprEndpoint) proto.endpoint).getCometPoller().add(
                             socket.getSocket().longValue(),
-                            proto.endpoint.getSoTimeout());
+                            proto.endpoint.getSoTimeout(),
+                            AprEndpoint.Poller.FLAGS_READ);
                 } else {
                     // Process a STOP directly
                     ((AprEndpoint) proto.endpoint).processSocket(
@@ -277,7 +279,8 @@ public class Http11AprProtocol extends A
                 // Upgraded
                 ((AprEndpoint) proto.endpoint).getPoller().add(
                         socket.getSocket().longValue(),
-                        (processor.getUpgradeInbound().getReadTimeout()));
+                        processor.getUpgradeInbound().getReadTimeout(),
+                        AprEndpoint.Poller.FLAGS_READ);
             }
         }
 

Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=1399023&r1=1399022&r2=1399023&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Tue 
Oct 16 22:19:09 2012
@@ -1110,6 +1110,9 @@ public class AprEndpoint extends Abstrac
      */
     public class Poller extends Thread {
 
+        public static final int FLAGS_READ = Poll.APR_POLLIN;
+        public static final int FLAGS_WRITE  = Poll.APR_POLLOUT;
+
         // Need two pollsets since the socketTimeout and the keep-alive timeout
         // can have different values.
         private long connectionPollset = 0;
@@ -1118,6 +1121,7 @@ public class AprEndpoint extends Abstrac
 
         private long[] addSocket;
         private int[] addSocketTimeout;
+        private int[] addSocketFlags;
 
         private volatile int addCount = 0;
 
@@ -1150,7 +1154,8 @@ public class AprEndpoint extends Abstrac
             desc = new long[size * 2];
             keepAliveCount = 0;
             addSocket = new long[size];
-            addSocketTimeout= new int[size];
+            addSocketTimeout = new int[size];
+            addSocketFlags = new int[size];
             addCount = 0;
         }
 
@@ -1204,8 +1209,10 @@ public class AprEndpoint extends Abstrac
          * @param socket    to add to the poller
          * @param timeout   read timeout (in milliseconds) to use with this
          *                  socket. Use -1 for infinite timeout
+         * @param flags     flags that define the events that are to be polled
+         *                  for
          */
-        public void add(long socket, int timeout) {
+        public void add(long socket, int timeout, int flags) {
             synchronized (this) {
                 // Add socket to the list. Newly added sockets will wait
                 // at most for pollTime before being polled
@@ -1220,6 +1227,7 @@ public class AprEndpoint extends Abstrac
                 }
                 addSocket[addCount] = socket;
                 addSocketTimeout[addCount] = timeout;
+                addSocketFlags[addCount] = flags;
                 addCount++;
                 this.notify();
             }
@@ -1278,7 +1286,7 @@ public class AprEndpoint extends Abstrac
                                     }
                                     int rv = Poll.addWithTimeout(
                                             connectionPollset, addSocket[i],
-                                            Poll.APR_POLLIN, timeout);
+                                            addSocketFlags[i], timeout);
                                     if (rv == Status.APR_SUCCESS) {
                                         successCount++;
                                     } else {
@@ -1661,7 +1669,8 @@ public class AprEndpoint extends Abstrac
                                     // If all done put the socket back in the 
poller for
                                     // processing of further requests
                                     getPoller().add(state.socket,
-                                            getKeepAliveTimeout());
+                                            getKeepAliveTimeout(),
+                                            Poller.FLAGS_READ);
                                 } else {
                                     // Close the socket since this is
                                     // the end of not keep-alive request.
@@ -1753,7 +1762,7 @@ public class AprEndpoint extends Abstrac
                 if (!deferAccept) {
                     if (setSocketOptions(socket.getSocket().longValue())) {
                         getPoller().add(socket.getSocket().longValue(),
-                                getSoTimeout());
+                                getSoTimeout(), Poller.FLAGS_READ);
                     } else {
                         // Close socket and pool
                         destroySocket(socket.getSocket().longValue());



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

Reply via email to