fhanik      2004/04/07 12:02:31

  Modified:    modules/cluster/src/share/org/apache/catalina/cluster/session
                        DeltaManager.java DeltaSession.java
               modules/cluster/src/share/org/apache/catalina/cluster/tcp
                        ReplicationListener.java TcpReplicationThread.java
                        ThreadPool.java WorkerThread.java
  Log:
  Two bug fixes
  
  1. access() on a session should not set isNew false
  2. fixed the blocking interestOps(), although selector.select() still doesn't wakeup 
when a new request comes in
     bug 28259
  
  Revision  Changes    Path
  1.20      +2 -2      
jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java
  
  Index: DeltaManager.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- DeltaManager.java 2 Apr 2004 14:42:20 -0000       1.19
  +++ DeltaManager.java 7 Apr 2004 19:02:30 -0000       1.20
  @@ -334,7 +334,7 @@
         session.setId(sessionId);
         session.resetDeltaRequest();
         // Initialize the properties of the new session and return it
  -
  +      
         sessionCounter++;
         
         
  
  
  
  1.21      +2 -2      
jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaSession.java
  
  Index: DeltaSession.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaSession.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- DeltaSession.java 1 Apr 2004 21:06:50 -0000       1.20
  +++ DeltaSession.java 7 Apr 2004 19:02:31 -0000       1.21
  @@ -523,6 +523,7 @@
       public void setNew(boolean isNew) {
           setNew(isNew,true);
       }
  +    
       public void setNew(boolean isNew, boolean addDeltaRequest) {
           this.isNew = isNew;
           if (addDeltaRequest && (deltaRequest!=null)) deltaRequest.setNew(isNew);
  @@ -643,7 +644,6 @@
        */
       public void access() {
   
  -        this.isNew = false;
           this.lastAccessedTime = this.thisAccessedTime;
           this.thisAccessedTime = System.currentTimeMillis();
   
  
  
  
  1.14      +16 -1     
jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationListener.java
  
  Index: ReplicationListener.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationListener.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ReplicationListener.java  27 Feb 2004 14:58:56 -0000      1.13
  +++ ReplicationListener.java  7 Apr 2004 19:02:31 -0000       1.14
  @@ -50,12 +50,14 @@
       private int tcpListenPort;
       private boolean isSenderSynchronized;
       
  +    private Object interestOpsMutex = new Object();
  +    
       public ReplicationListener() {
       }
   
       public void start() {
           try {
  -            pool = new ThreadPool(tcpThreadCount, TcpReplicationThread.class);
  +            pool = new ThreadPool(tcpThreadCount, TcpReplicationThread.class, 
interestOpsMutex);
               if ( "auto".equals(tcpListenAddress) ) {
                   tcpListenAddress = java.net.InetAddress.getLocalHost().
                       getHostAddress();
  @@ -110,6 +112,16 @@
   
                   int n = selector.select(tcpSelectorTimeout);
                   if (n == 0) {
  +                    //there is a good chance that we got here 
  +                    //because the TcpReplicationThread called
  +                    //selector wakeup().
  +                    //if that happens, we must ensure that that
  +                    //thread has enough time to call interestOps
  +                    synchronized (interestOpsMutex) {
  +                        //if we got the lock, means there are no
  +                        //keys trying to register for the 
  +                        //interestOps method
  +                    }
                       continue; // nothing to do
                   }
                   // get an iterator over the set of selected keys
  @@ -242,6 +254,9 @@
   
       public int getPort() {
           return getTcpListenPort();
  +    }
  +    public Object getInterestOpsMutex() {
  +        return interestOpsMutex;
       }
   
   }
  
  
  
  1.10      +10 -3     
jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/TcpReplicationThread.java
  
  Index: TcpReplicationThread.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/TcpReplicationThread.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TcpReplicationThread.java 27 Feb 2004 14:58:56 -0000      1.9
  +++ TcpReplicationThread.java 7 Apr 2004 19:02:31 -0000       1.10
  @@ -139,9 +139,16 @@
               return;
           }
           // resume interest in OP_READ, OP_WRITE
  -        key.interestOps (key.interestOps() | SelectionKey.OP_READ);
  -        // cycle the selector so this key is active again
  -        key.selector().wakeup();
  +        int resumeOps = key.interestOps() | SelectionKey.OP_READ;
  +        long _debugstart = System.currentTimeMillis();
  +        //acquire the interestOps mutex
  +        Object mutex = this.getPool().getInterestOpsMutex();
  +        synchronized (mutex) {
  +            // cycle the selector so this key is active again
  +            key.selector().wakeup();
  +            key.interestOps(resumeOps);
  +        }
  +        
       }
   
       private void sendAck(SelectionKey key, SocketChannel channel) {
  
  
  
  1.7       +6 -1      
jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ThreadPool.java
  
  Index: ThreadPool.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ThreadPool.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ThreadPool.java   27 Feb 2004 14:58:56 -0000      1.6
  +++ ThreadPool.java   7 Apr 2004 19:02:31 -0000       1.7
  @@ -37,9 +37,11 @@
   
       List idle = new LinkedList();
       Object mutex = new Object();
  +    Object interestOpsMutex = null;
   
  -    ThreadPool (int poolSize, Class threadClass) throws Exception {
  +    ThreadPool (int poolSize, Class threadClass, Object interestOpsMutex) throws 
Exception {
           // fill up the pool with worker threads
  +        this.interestOpsMutex = interestOpsMutex;
           for (int i = 0; i < poolSize; i++) {
               WorkerThread thread = (WorkerThread)threadClass.newInstance();
               thread.setPool(this);
  @@ -90,5 +92,8 @@
               idle.add (worker);
               mutex.notify();
           }
  +    }
  +    public Object getInterestOpsMutex() {
  +        return interestOpsMutex;
       }
   }
  
  
  
  1.7       +4 -0      
jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/WorkerThread.java
  
  Index: WorkerThread.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/WorkerThread.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- WorkerThread.java 27 Feb 2004 14:58:56 -0000      1.6
  +++ WorkerThread.java 7 Apr 2004 19:02:31 -0000       1.7
  @@ -28,6 +28,10 @@
       public void setPool(ThreadPool pool) {
           this.pool = pool;
       }
  +    
  +    public ThreadPool getPool() {
  +        return pool;
  +    }
   
       public void close()
       {
  
  
  

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

Reply via email to