Author: remm
Date: Tue May 29 17:17:11 2007
New Revision: 542701

URL: http://svn.apache.org/viewvc?view=rev&rev=542701
Log:
- More plumbing code. So far, the API looks fine to expose the needed 
functionality.

Modified:
    tomcat/sandbox/comet/java/org/apache/catalina/connector/CometEventImpl.java
    tomcat/sandbox/comet/java/org/apache/coyote/http11/Http11AprProcessor.java
    tomcat/sandbox/comet/java/org/apache/coyote/http11/Http11AprProtocol.java
    tomcat/sandbox/comet/java/org/apache/tomcat/util/net/AprEndpoint.java

Modified: 
tomcat/sandbox/comet/java/org/apache/catalina/connector/CometEventImpl.java
URL: 
http://svn.apache.org/viewvc/tomcat/sandbox/comet/java/org/apache/catalina/connector/CometEventImpl.java?view=diff&rev=542701&r1=542700&r2=542701
==============================================================================
--- tomcat/sandbox/comet/java/org/apache/catalina/connector/CometEventImpl.java 
(original)
+++ tomcat/sandbox/comet/java/org/apache/catalina/connector/CometEventImpl.java 
Tue May 29 17:17:11 2007
@@ -19,14 +19,12 @@
 package org.apache.catalina.connector;
 
 import java.io.IOException;
-import java.util.HashSet;
-import javax.servlet.ServletException;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.catalina.CometEvent;
 import org.apache.catalina.util.StringManager;
-import org.apache.coyote.ActionCode;
 
 public class CometEventImpl implements CometEvent {
 
@@ -132,7 +130,7 @@
      *        may be requested by using the sendNotify method
      */
     public void configure(boolean read, boolean write) {
-        
+        request.configure(read, write);
     }
 
     /**
@@ -143,7 +141,7 @@
      *        will be sent to the servlet
      */
     public void callback(boolean write) {
-        
+        request.callback(write);
     }
 
     public String toString() {

Modified: 
tomcat/sandbox/comet/java/org/apache/coyote/http11/Http11AprProcessor.java
URL: 
http://svn.apache.org/viewvc/tomcat/sandbox/comet/java/org/apache/coyote/http11/Http11AprProcessor.java?view=diff&rev=542701&r1=542700&r2=542701
==============================================================================
--- tomcat/sandbox/comet/java/org/apache/coyote/http11/Http11AprProcessor.java 
(original)
+++ tomcat/sandbox/comet/java/org/apache/coyote/http11/Http11AprProcessor.java 
Tue May 29 17:17:11 2007
@@ -317,9 +317,29 @@
      */
     protected String server = null;
 
+    
+    protected int cometTimeout = -1;
+    protected boolean readNotifications = true;
+    protected boolean writeNotifications = false;
+    
 
     // ------------------------------------------------------------- Properties
 
+    
+    public boolean getReadNotifications() {
+        return readNotifications;
+    }
+    
+
+    public boolean getWriteNotifications() {
+        return readNotifications;
+    }
+    
+
+    public int getCometTimeout() {
+        return cometTimeout;
+    }
+    
 
     /**
      * Return compression level.
@@ -686,8 +706,8 @@
     /**
      * Set the upload timeout.
      */
-    public void setTimeout( int timeouts ) {
-        timeout = timeouts ;
+    public void setTimeout(int timeout) {
+        this.timeout = timeout;
     }
 
     /**
@@ -1199,6 +1219,15 @@
             comet = true;
         } else if (actionCode == ActionCode.ACTION_COMET_END) {
             comet = false;
+        } else if (actionCode == ActionCode.ACTION_COMET_READ_NOTIFICATIONS) {
+            readNotifications = ((Boolean) param).booleanValue();
+        } else if (actionCode == ActionCode.ACTION_COMET_WRITE_NOTIFICATIONS) {
+            writeNotifications = ((Boolean) param).booleanValue();
+            // FIXME: If true, should switch to non blocking mode for the 
socket
+        } else if (actionCode == ActionCode.ACTION_COMET_CALLBACK) {
+            endpoint.getCometPoller().add(socket, timeout, false, ((Boolean) 
param).booleanValue());
+        } else if (actionCode == ActionCode.ACTION_COMET_TIMEOUT) {
+            cometTimeout = ((Integer) param).intValue();
         }
 
     }

Modified: 
tomcat/sandbox/comet/java/org/apache/coyote/http11/Http11AprProtocol.java
URL: 
http://svn.apache.org/viewvc/tomcat/sandbox/comet/java/org/apache/coyote/http11/Http11AprProtocol.java?view=diff&rev=542701&r1=542700&r2=542701
==============================================================================
--- tomcat/sandbox/comet/java/org/apache/coyote/http11/Http11AprProtocol.java 
(original)
+++ tomcat/sandbox/comet/java/org/apache/coyote/http11/Http11AprProtocol.java 
Tue May 29 17:17:11 2007
@@ -563,7 +563,8 @@
                             proto.endpoint.getPoller().add(socket);
                         }
                     } else {
-                        proto.endpoint.getCometPoller().add(socket);
+                        proto.endpoint.getCometPoller().add(socket, 
result.getCometTimeout(), 
+                                result.getReadNotifications(), false);
                     }
                 }
             }
@@ -587,7 +588,8 @@
                     // processed by this thread will use either a new or a 
recycled
                     // processor.
                     connections.put(socket, processor);
-                    proto.endpoint.getCometPoller().add(socket);
+                    proto.endpoint.getCometPoller().add(socket, 
processor.getCometTimeout(), 
+                            processor.getReadNotifications(), false);
                 } else {
                     recycledProcessors.offer(processor);
                 }

Modified: tomcat/sandbox/comet/java/org/apache/tomcat/util/net/AprEndpoint.java
URL: 
http://svn.apache.org/viewvc/tomcat/sandbox/comet/java/org/apache/tomcat/util/net/AprEndpoint.java?view=diff&rev=542701&r1=542700&r2=542701
==============================================================================
--- tomcat/sandbox/comet/java/org/apache/tomcat/util/net/AprEndpoint.java 
(original)
+++ tomcat/sandbox/comet/java/org/apache/tomcat/util/net/AprEndpoint.java Tue 
May 29 17:17:11 2007
@@ -1240,6 +1240,42 @@
             }
         }
 
+        // FIXME: Maybe CometPoller extends Poller could make some sense 
+        /**
+         * Add specified socket and associated pool to the poller. The socket 
will
+         * be added to a temporary array, and polled first after a maximum 
amount
+         * of time equal to pollTime (in most cases, latency will be much 
lower,
+         * however). Note: If both read and write are false, the socket will 
only
+         * be checked for timeout; if the socket was already present in the 
poller, 
+         * a callback event will be generated and the socket will be removed 
from the
+         * poller.
+         *
+         * @param socket to add to the poller
+         * @param timeout to use for this connection
+         * @param read to do read polling
+         * @param write to do write polling
+         */
+        public void add(long socket, int timeout, boolean read, boolean write) 
{
+            // FIXME: Implement. At the moment, no support for both read and 
write polling, although
+            // there's no problem in theory.
+            synchronized (this) {
+                // Add socket to the list. Newly added sockets will wait
+                // at most for pollTime before being polled
+                if (addCount >= addS.length) {
+                    // Can't do anything: close the socket right away
+                    if (comet) {
+                        processSocket(socket, SocketStatus.ERROR);
+                    } else {
+                        Socket.destroy(socket);
+                    }
+                    return;
+                }
+                addS[addCount] = socket;
+                addCount++;
+                this.notify();
+            }
+        }
+
         /**
          * The background thread that listens for incoming TCP/IP connections 
and
          * hands them off to an appropriate processor.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to