Minor optimizations
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 14 Apr 2007 02:48:45 +0000 (02:48 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 14 Apr 2007 02:48:45 +0000 (02:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@528744 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/tomcat/util/net/NioEndpoint.java
java/org/apache/tomcat/util/net/SocketProperties.java

index 2e76cad..b26da8f 100644 (file)
@@ -1326,7 +1326,7 @@ public class NioEndpoint {
         
         public void addEvent(Runnable event) {
             events.offer(event);
-            if ( wakeupCounter.incrementAndGet() < 3 ) selector.wakeup();
+            if ( wakeupCounter.incrementAndGet() == 1 || wakeupCounter.get() > 5 ) selector.wakeup();
         }
 
         /**
@@ -1428,7 +1428,10 @@ public class NioEndpoint {
                     int keyCount = 0;
                     try {
                         if ( !close ) {
-                            keyCount = selector.select(selectorTimeout);
+                            if ( wakeupCounter.get() > 0 )
+                                keyCount = selector.selectNow(); //we have events that need to be processed
+                            else
+                                keyCount = selector.select(selectorTimeout);
                             wakeupCounter.set(0);
                         }
                         if (close) {
index 6551834..4392a23 100644 (file)
@@ -82,7 +82,7 @@ public class SocketProperties {
      * The application write buffer size in bytes\r
      * Default value is txBufSize\r
      */\r
-    protected int appWriteBufSize = 8192;\r
+    protected int appWriteBufSize = txBufSize;\r
 \r
     /**\r
      * NioChannel pool size for the endpoint,\r