Author: fhanik
Date: Wed Oct 25 07:31:25 2006
New Revision: 467669

URL: http://svn.apache.org/viewvc?view=rev&rev=467669
Log:
Code clean up, last pieces to make is a the KeyAttachment object and the 
Runnable used for addEvent to be non GC objects, as these events happen very 
frequently

Modified:
    
tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java?view=diff&rev=467669&r1=467668&r2=467669
==============================================================================
--- 
tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java 
(original)
+++ 
tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java 
Wed Oct 25 07:31:25 2006
@@ -594,31 +594,6 @@
         }
     }
 
-    private void addToReadQueue(final SelectionKey key, final KeyAttachment 
att) {
-        att.setWakeUp(true);
-        att.getPoller().addEvent(
-            new Runnable() {
-            public void run() {
-                try {
-                    if (key != null) {
-                        key.interestOps(SelectionKey.OP_READ);
-                        att.interestOps(SelectionKey.OP_READ);
-                    }
-                } catch (CancelledKeyException ckx) {
-                    try {
-                        if ( att != null ) {
-                            att.setError(true); //set to collect this socket 
immediately
-                            att.setWakeUp(false);
-                        }
-                        try {socket.close();}catch (Exception ignore){}
-                        if ( socket.isOpen() ) socket.close(true);
-                    } catch (Exception ignore) {}
-                }
-            }
-        });
-    }
-
-
     /**
      * Parse the HTTP headers.
      */

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?view=diff&rev=467669&r1=467668&r2=467669
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Wed 
Oct 25 07:31:25 2006
@@ -156,6 +156,7 @@
             SelectionKey key = 
sel!=null?socket.getIOChannel().keyFor(sel):null;
             KeyAttachment att = key!=null?(KeyAttachment)key.attachment():null;
             if ( att!=null ) att.reset();
+            if ( key!=null ) key.attach(null);
             //avoid over growing our cache or add after we have stopped
             if ( running && (!paused) && (size() < 
socketProperties.getDirectBufferPool()) ) return super.offer(socket);
             else return false;
@@ -986,9 +987,6 @@
         }
         
         public void addEvent(Runnable event) {
-            //synchronized (events) {
-            //    events.add(event);
-            //}
             events.offer(event);
             if ( wakeupCounter.incrementAndGet() < 3 ) selector.wakeup();
         }
@@ -1004,7 +1002,6 @@
         public void add(final NioChannel socket) {
             final SelectionKey key = socket.getIOChannel().keyFor(selector);
             final KeyAttachment att = (KeyAttachment)key.attachment();
-            if ( att != null ) att.setWakeUp(false);
             Runnable r = new Runnable() {
                 public void run() {
                     try {
@@ -1137,10 +1134,7 @@
                             attachment.interestOps(0);
                             NioChannel channel = attachment.getChannel();
                             if (sk.isReadable() || sk.isWritable() ) {
-                                if ( attachment.getWakeUp() ) {
-                                    attachment.setWakeUp(false);
-                                    synchronized (attachment.getMutex()) 
{attachment.getMutex().notifyAll();}
-                                } else if ( attachment.getComet() ) {
+                                if ( attachment.getComet() ) {
                                     if (!processSocket(channel, 
SocketStatus.OPEN))
                                         processSocket(channel, 
SocketStatus.DISCONNECT);
                                 } else {
@@ -1211,7 +1205,6 @@
         }
         public void reset() {
             //mutex = new Object();
-            wakeUp = false;
             lastAccess = System.currentTimeMillis();
             currentAccess = false;
             comet = false;
@@ -1228,8 +1221,6 @@
         public boolean getComet() { return comet; }
         public boolean getCurrentAccess() { return currentAccess; }
         public void setCurrentAccess(boolean access) { currentAccess = access; 
}
-        public boolean getWakeUp() { return wakeUp; }
-        public void setWakeUp(boolean wakeUp) { this.wakeUp = wakeUp; }
         public Object getMutex() {return mutex;}
         public void setTimeout(long timeout) {this.timeout = timeout;}
         public long getTimeout() {return this.timeout;}
@@ -1242,7 +1233,6 @@
         public int interestOps() { return interestOps;}
         public int interestOps(int ops) { this.interestOps  = ops; return ops; 
}
         protected Object mutex = new Object();
-        protected boolean wakeUp = false;
         protected long lastAccess = System.currentTimeMillis();
         protected boolean currentAccess = false;
         protected boolean comet = false;
@@ -1417,11 +1407,9 @@
                                     } catch (CancelledKeyException ckx) {
                                         try {
                                             if ( fk != null && fk.attachment() 
!= null ) {
-
                                                 ka.setError(true); //set to 
collect this socket immediately
                                                 try 
{ka.getChannel().getIOChannel().socket().close();}catch(Exception ignore){}
                                                 try 
{ka.getChannel().close();}catch(Exception ignore){}
-                                                ka.setWakeUp(false);
                                             }
                                         } catch (Exception ignore) {}
                                     }



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

Reply via email to