tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r998468 - in /tomcat/trunk/java/org/apache/tomcat/util/net: AbstractEndpoint.java AprEndpoint.java JIoEndpoint.java NioEndpoint.java
Date Sat, 18 Sep 2010 13:47:49 GMT
Author: markt
Date: Sat Sep 18 13:47:49 2010
New Revision: 998468

URL: http://svn.apache.org/viewvc?rev=998468&view=rev
Log:
Code clean-up
Use a single method for unlockAccept

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java
    tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
    tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
    tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java?rev=998468&r1=998467&r2=998468&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java Sat Sep 18 13:47:49
2010
@@ -17,6 +17,7 @@
 package org.apache.tomcat.util.net;
 
 import java.io.File;
+import java.io.OutputStreamWriter;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.util.StringTokenizer;
@@ -303,7 +304,8 @@ public abstract class AbstractEndpoint {
     public void setThreadPriority(int threadPriority) { this.threadPriority = threadPriority;
}
     public int getThreadPriority() { return threadPriority; }
 
-
+    protected abstract boolean getDeferAccept();
+    
     /**
      * Generic properties, introspected
      */
@@ -410,6 +412,19 @@ public abstract class AbstractEndpoint {
                 getLog().debug("About to unlock socket for:"+saddr);
             }
             s.connect(saddr,getSocketProperties().getUnlockTimeout());
+            if (getDeferAccept()) {
+                /*
+                 * In the case of a deferred accept / accept filters we need to
+                 * send data to wake up the accept. Send OPTIONS * to bypass
+                 * even BSD accept filters. The Acceptor will discard it.
+                 */
+                OutputStreamWriter sw;
+
+                sw = new OutputStreamWriter(s.getOutputStream(), "ISO-8859-1");
+                sw.write("OPTIONS * HTTP/1.0\r\n" +
+                         "User-Agent: Tomcat wakeup connection\r\n\r\n");
+                sw.flush();
+            }
             if (getLog().isDebugEnabled()) {
                 getLog().debug("Socket unlock completed for:"+saddr);
             }

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=998468&r1=998467&r2=998468&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Sat Sep 18 13:47:49 2010
@@ -587,59 +587,6 @@ public class AprEndpoint extends Abstrac
 
 
     /**
-     * Unlock the server socket accept using a bogus connection.
-     */
-    @Override
-    protected void unlockAccept() {
-        java.net.Socket s = null;
-        InetSocketAddress saddr = null;
-        try {
-            // Need to create a connection to unlock the accept();
-            if (getAddress() == null) {
-                saddr = new InetSocketAddress("localhost", getPort());
-            } else {
-                saddr = new InetSocketAddress(getAddress(),getPort());
-            }
-            s = new java.net.Socket();
-            s.setSoTimeout(getSocketProperties().getSoTimeout());
-            // TODO Consider hard-coding to s.setSoLinger(true,0)
-            s.setSoLinger(getSocketProperties().getSoLingerOn(),getSocketProperties().getSoLingerTime());
-            if (log.isDebugEnabled()) {
-                log.debug("About to unlock socket for:"+saddr);
-            }
-            s.connect(saddr,getSocketProperties().getUnlockTimeout());
-            /*
-             * In the case of a deferred accept / accept filters we need to
-             * send data to wake up the accept. Send OPTIONS * to bypass even
-             * BSD accept filters. The Acceptor will discard it.
-             */
-            if (deferAccept) {
-                OutputStreamWriter sw;
-
-                sw = new OutputStreamWriter(s.getOutputStream(), "ISO-8859-1");
-                sw.write("OPTIONS * HTTP/1.0\r\n" +
-                         "User-Agent: Tomcat wakeup connection\r\n\r\n");
-                sw.flush();
-            }
-            if (log.isDebugEnabled()) {
-                log.debug("Socket unlock completed for:"+saddr);
-            }
-        } catch(Exception e) {
-            if (log.isDebugEnabled()) {
-                log.debug(sm.getString("endpoint.debug.unlock", "" + getPort()), e);
-            }
-        } finally {
-            if (s != null) {
-                try {
-                    s.close();
-                } catch (Exception e) {
-                    // Ignore
-                }
-            }
-        }
-    }
-
-    /**
      * Stop the endpoint. This will cause all processing threads to stop.
      */
     public void stop() {

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java?rev=998468&r1=998467&r2=998468&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java Sat Sep 18 13:47:49 2010
@@ -99,6 +99,16 @@ public class JIoEndpoint extends Abstrac
     }
 
 
+    /**
+     * Is deferAccept supported?
+     */
+    @Override
+    public boolean getDeferAccept() {
+        // Not supported
+        return false;
+    }
+
+
     // ------------------------------------------------ Handler Inner Interface
 
     /**

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?rev=998468&r1=998467&r2=998468&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Sat Sep 18 13:47:49 2010
@@ -374,6 +374,15 @@ public class NioEndpoint extends Abstrac
         this.useSendfile = useSendfile;
     }
 
+    /**
+     * Is deferAccept supported?
+     */
+    @Override
+    public boolean getDeferAccept() {
+        // Not supported
+        return false;
+    }
+
     public void setOomParachute(int oomParachute) {
         this.oomParachute = oomParachute;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message