Add the additional SocketStatus event types, its up to the connector implementation...
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 29 May 2007 10:44:51 +0000 (10:44 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 29 May 2007 10:44:51 +0000 (10:44 +0000)
Currently the functionality is backwards compatible as OPEN changed to OPEN_READ

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@542482 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/connector/CoyoteAdapter.java
java/org/apache/tomcat/util/net/AprEndpoint.java
java/org/apache/tomcat/util/net/NioEndpoint.java
java/org/apache/tomcat/util/net/SocketStatus.java

index a17f0c7..d74672d 100644 (file)
@@ -123,7 +123,27 @@ public class CoyoteAdapter
             try {
                 if ( event!=null && (event instanceof CometEventImpl)) 
                     ((CometEventImpl)event).setWorkerThread();
-                if (status == SocketStatus.OPEN) {
+                if (status == SocketStatus.OPEN_CALLBACK) {
+                    if (response.isClosed()) {
+                        // The event has been closed asynchronously, so call end instead of
+                        // read to cleanup the pipeline
+                        request.getEvent().setEventType(CometEvent.EventType.END);
+                        request.getEvent().setEventSubType(null);
+                    } else {
+                        request.getEvent().setEventType(CometEvent.EventType.CALLBACK);
+                        request.getEvent().setEventSubType(null);
+                    }
+                } else if (status == SocketStatus.OPEN_WRITE) {
+                    if (response.isClosed()) {
+                        // The event has been closed asynchronously, so call end instead of
+                        // read to cleanup the pipeline
+                        request.getEvent().setEventType(CometEvent.EventType.END);
+                        request.getEvent().setEventSubType(null);
+                    } else {
+                        request.getEvent().setEventType(CometEvent.EventType.WRITE);
+                        request.getEvent().setEventSubType(null);
+                    }
+                } else if (status == SocketStatus.OPEN_READ) {
                     if (response.isClosed()) {
                         // The event has been closed asynchronously, so call end instead of
                         // read to cleanup the pipeline
@@ -274,7 +294,7 @@ public class CoyoteAdapter
                     if (!response.isClosed() && !response.isError()) {
                         if (request.getAvailable()) {
                             // Invoke a read event right away if there are available bytes
-                            if (event(req, res, SocketStatus.OPEN)) {
+                            if (event(req, res, SocketStatus.OPEN_READ)) {
                                 comet = true;
                                 res.action(ActionCode.ACTION_COMET_BEGIN, null);
                             }
index b23a9ef..f8d8d82 100644 (file)
@@ -1301,7 +1301,7 @@ public class AprEndpoint {
                             // Check for failed sockets and hand this socket off to a worker
                             if (((desc[n*2] & Poll.APR_POLLHUP) == Poll.APR_POLLHUP)
                                     || ((desc[n*2] & Poll.APR_POLLERR) == Poll.APR_POLLERR)
-                                    || (comet && (!processSocket(desc[n*2+1], SocketStatus.OPEN))) 
+                                    || (comet && (!processSocket(desc[n*2+1], SocketStatus.OPEN_READ))) 
                                     || (!comet && (!processSocket(desc[n*2+1])))) {
                                 // Close socket and clear pool
                                 if (comet) {
index 3f8fbd7..e122a00 100644 (file)
@@ -1501,7 +1501,7 @@ public class NioEndpoint {
                             //check if thread is available
                             if ( isWorkerAvailable() ) {
                                 unreg(sk, attachment, sk.readyOps());
-                                if (!processSocket(channel, SocketStatus.OPEN))
+                                if (!processSocket(channel, SocketStatus.OPEN_READ))
                                     processSocket(channel, SocketStatus.DISCONNECT);
                             } else {
                                 result = false;
index 58ee7f1..bd98080 100644 (file)
@@ -23,5 +23,5 @@ package org.apache.tomcat.util.net;
  * @author remm
  */
 public enum SocketStatus {
-    OPEN, STOP, TIMEOUT, DISCONNECT, ERROR
+    OPEN_READ, OPEN_WRITE, OPEN_CALLBACK, STOP, TIMEOUT, DISCONNECT, ERROR
 }