You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2006/09/11 08:09:57 UTC

svn commit: r442109 [2/2] - in /tomcat/sandbox/tomcat-lite: ./ bin/ java/org/apache/tomcat/lite/ java/org/apache/tomcat/lite/http/ java/org/apache/tomcat/servlets/file/ java/org/apache/tomcat/servlets/session/ java/org/apache/tomcat/standalone/ java/or...

Modified: tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/loader/ModuleClassLoader.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/loader/ModuleClassLoader.java?view=diff&rev=442109&r1=442108&r2=442109
==============================================================================
--- tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/loader/ModuleClassLoader.java (original)
+++ tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/loader/ModuleClassLoader.java Sun Sep 10 23:09:56 2006
@@ -24,8 +24,6 @@
 import java.net.URLClassLoader;
 import java.util.Enumeration;
 
-import org.apache.catalina.LifecycleException;
-
 /*
  * Initially, I started with WebappClassLoader attempting to clean up and
  * refactor it. Because of complexity and very weird ( and likely buggy ) 

Modified: tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/net/http11/Endpoint.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/net/http11/Endpoint.java?view=diff&rev=442109&r1=442108&r2=442109
==============================================================================
--- tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/net/http11/Endpoint.java (original)
+++ tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/net/http11/Endpoint.java Sun Sep 10 23:09:56 2006
@@ -17,9 +17,7 @@
 package org.apache.tomcat.util.net.http11;
 
 import java.io.IOException;
-import java.net.BindException;
 import java.net.InetAddress;
-import java.net.ServerSocket;
 import java.net.Socket;
 import java.net.SocketException;
 import java.util.ArrayList;
@@ -48,7 +46,7 @@
 
     // Socket properties
     protected static final int BACKLOG = 100;
-    protected static final int TIMEOUT = 1000;
+    protected static final int TIMEOUT = 5000;
     protected int backlog = BACKLOG;
     protected int serverTimeout = TIMEOUT;
     protected InetAddress inet;

Modified: tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/net/http11/Http11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/net/http11/Http11Processor.java?view=diff&rev=442109&r1=442108&r2=442109
==============================================================================
--- tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/net/http11/Http11Processor.java (original)
+++ tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/net/http11/Http11Processor.java Sun Sep 10 23:09:56 2006
@@ -50,7 +50,6 @@
 import org.apache.tomcat.util.buf.MessageBytes;
 import org.apache.tomcat.util.http.FastHttpDateFormat;
 import org.apache.tomcat.util.http.MimeHeaders;
-import org.apache.tomcat.util.net.SSLSupport;
 import org.apache.tomcat.util.net.simple.SimpleEndpoint;
 import org.apache.tomcat.util.res.StringManager;
 
@@ -190,12 +189,6 @@
 
 
     /**
-     * SSL information.
-     */
-    protected SSLSupport sslSupport;
-
-
-    /**
      * Socket associated with the current connection.
      */
     protected Socket socket;
@@ -641,14 +634,6 @@
 
 
     /**
-     * Set the SSL information for this HTTP connection.
-     */
-    public void setSSLSupport(SSLSupport sslSupport) {
-        this.sslSupport = sslSupport;
-    }
-
-
-    /**
      * Set the flag to control upload time-outs.
      */
     public void setDisableUploadTimeout(boolean isDisabled) {
@@ -890,9 +875,6 @@
         // Recycle
         inputBuffer.recycle();
         outputBuffer.recycle();
-
-        // Recycle ssl info
-        sslSupport = null;
     }
 
 
@@ -985,29 +967,8 @@
 
         } else if (actionCode == ActionCode.ACTION_REQ_SSL_ATTRIBUTE ) {
 
-            try {
-                if (sslSupport != null) {
-                    Object sslO = sslSupport.getCipherSuite();
-                    if (sslO != null)
-                        request.setAttribute
-                            (SSLSupport.CIPHER_SUITE_KEY, sslO);
-                    sslO = sslSupport.getPeerCertificateChain(false);
-                    if (sslO != null)
-                        request.setAttribute
-                            (SSLSupport.CERTIFICATE_KEY, sslO);
-                    sslO = sslSupport.getKeySize();
-                    if (sslO != null)
-                        request.setAttribute
-                            (SSLSupport.KEY_SIZE_KEY, sslO);
-                    sslO = sslSupport.getSessionId();
-                    if (sslO != null)
-                        request.setAttribute
-                            (SSLSupport.SESSION_ID_KEY, sslO);
-                }
-            } catch (Exception e) {
-                log.warn(sm.getString("http11processor.socket.ssl"), e);
-            }
-
+            // nothing - nio implementation later
+            
         } else if (actionCode == ActionCode.ACTION_REQ_HOST_ADDR_ATTRIBUTE) {
 
             if ((remoteAddr == null) && (socket != null)) {
@@ -1067,26 +1028,7 @@
             request.setLocalPort(localPort);
 
         } else if (actionCode == ActionCode.ACTION_REQ_SSL_CERTIFICATE) {
-            if( sslSupport != null) {
-                /*
-                 * Consume and buffer the request body, so that it does not
-                 * interfere with the client's handshake messages
-                 */
-                InputFilter[] inputFilters = inputBuffer.getFilters();
-                ((BufferedInputFilter) inputFilters[Constants.BUFFERED_FILTER])
-                    .setLimit(maxSavePostSize);
-                inputBuffer.addActiveFilter
-                    (inputFilters[Constants.BUFFERED_FILTER]);
-                try {
-                    Object sslO = sslSupport.getPeerCertificateChain(true);
-                    if( sslO != null) {
-                        request.setAttribute
-                            (SSLSupport.CERTIFICATE_KEY, sslO);
-                    }
-                } catch (Exception e) {
-                    log.warn(sm.getString("http11processor.socket.ssl"), e);
-                }
-            }
+
         } else if (actionCode == ActionCode.ACTION_REQ_SET_BODY_REPLAY) {
             ByteChunk body = (ByteChunk) param;
             
@@ -1136,9 +1078,9 @@
         http09 = false;
         contentDelimitation = false;
         expectation = false;
-        if (sslSupport != null) {
-            request.scheme().setString("https");
-        }
+//        if (sslSupport != null) {
+//            request.scheme().setString("https");
+//        }
         MessageBytes protocolMB = request.protocol();
         if (protocolMB.equals(Constants.HTTP_11)) {
             http11 = true;
@@ -1342,13 +1284,13 @@
         }
 
         if (colonPos < 0) {
-            if (sslSupport == null) {
+//            if (sslSupport == null) {
                 // 80 - Default HTTP port
                 request.setServerPort(80);
-            } else {
-                // 443 - Default HTTPS port
-                request.setServerPort(443);
-            }
+//            } else {
+//                // 443 - Default HTTPS port
+//                request.setServerPort(443);
+//            }
             request.serverName().setChars(hostNameC, 0, valueL);
         } else {
 

Modified: tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/net/http11/Http11Protocol.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/net/http11/Http11Protocol.java?view=diff&rev=442109&r1=442108&r2=442109
==============================================================================
--- tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/net/http11/Http11Protocol.java (original)
+++ tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/net/http11/Http11Protocol.java Sun Sep 10 23:09:56 2006
@@ -21,8 +21,6 @@
 import java.util.HashMap;
 import java.util.Iterator;
 
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
 import org.apache.coyote.ActionCode;
@@ -30,11 +28,7 @@
 import org.apache.coyote.Adapter;
 import org.apache.coyote.ProtocolHandler;
 import org.apache.coyote.RequestGroupInfo;
-import org.apache.coyote.RequestInfo;
 import org.apache.coyote.http11.Constants;
-import org.apache.tomcat.util.modeler.Registry;
-import org.apache.tomcat.util.net.SSLImplementation;
-import org.apache.tomcat.util.net.ServerSocketFactory;
 import org.apache.tomcat.util.net.nio.NioEndpoint;
 import org.apache.tomcat.util.net.simple.SimpleEndpoint;
 import org.apache.tomcat.util.res.StringManager;
@@ -48,8 +42,7 @@
  * @author Remy Maucherat
  * @author Costin Manolache
  */
-public class Http11Protocol 
-    implements ProtocolHandler, MBeanRegistration {
+public class Http11Protocol implements ProtocolHandler {
 
 
     protected static org.apache.commons.logging.Log log
@@ -65,7 +58,8 @@
     // ------------------------------------------------------------ Constructor
 
 
-    public Http11Protocol() {
+    public Http11Protocol(Endpoint ep) {
+        this.endpoint = ep;
         endpoint.setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
         endpoint.setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
         //setServerSoTimeout(Constants.DEFAULT_SERVER_SOCKET_TIMEOUT);
@@ -77,18 +71,14 @@
 
 
     protected Http11ConnectionHandler cHandler = new Http11ConnectionHandler(this);
-    protected NioEndpoint endpoint = new NioEndpoint();
+    //protected NioEndpoint endpoint = new NioEndpoint();
+    protected Endpoint endpoint;
 
     // *
     protected ObjectName tpOname = null;
     // *
     protected ObjectName rgOname = null;
 
-
-    protected ServerSocketFactory socketFactory = null;
-    protected SSLImplementation sslImplementation = null;
-
-
     // ----------------------------------------- ProtocolHandler Implementation
     // *
 
@@ -145,15 +135,6 @@
         }
         */
 
-        if (socketFactory!=null) {
-            Iterator attE = attributes.keySet().iterator();
-            while( attE.hasNext() ) {
-                String key = (String)attE.next();
-                Object v=attributes.get(key);
-                socketFactory.setAttribute(key, v);
-            }
-        }
-        
         try {
             endpoint.initEndpoint();
         } catch (Exception ex) {
@@ -166,29 +147,12 @@
     }
 
     public void start() throws Exception {
-        if (this.domain != null) {
-            try {
-                tpOname = new ObjectName
-                    (domain + ":" + "type=ThreadPool,name=" + getName());
-                Registry.getRegistry(null, null)
-                    .registerComponent(endpoint, tpOname, null );
-            } catch (Exception e) {
-                log.error("Can't register endpoint");
-            }
-            rgOname=new ObjectName
-                (domain + ":type=GlobalRequestProcessor,name=" + getName());
-            Registry.getRegistry(null, null).registerComponent
-                ( cHandler.global, rgOname, null );
-        }
-
         try {
             endpoint.startEndpoint();
         } catch (Exception ex) {
             log.error(sm.getString("http11protocol.endpoint.starterror"), ex);
             throw ex;
         }
-        if (log.isInfoEnabled())
-            log.info(sm.getString("http11protocol.start", getName()));
     }
 
     public void pause() throws Exception {
@@ -198,8 +162,6 @@
             log.error(sm.getString("http11protocol.endpoint.pauseerror"), ex);
             throw ex;
         }
-        if (log.isInfoEnabled())
-            log.info(sm.getString("http11protocol.pause", getName()));
     }
 
     public void resume() throws Exception {
@@ -209,18 +171,12 @@
             log.error(sm.getString("http11protocol.endpoint.resumeerror"), ex);
             throw ex;
         }
-        if (log.isInfoEnabled())
-            log.info(sm.getString("http11protocol.resume", getName()));
     }
 
     public void destroy() throws Exception {
         if (log.isInfoEnabled())
             log.info(sm.getString("http11protocol.stop", getName()));
         endpoint.stopEndpoint();
-        if (tpOname!=null)
-            Registry.getRegistry(null, null).unregisterComponent(tpOname);
-        if (rgOname != null)
-            Registry.getRegistry(null, null).unregisterComponent(rgOname);
     }
 
     
@@ -499,33 +455,12 @@
                     processor.setMaxSavePostSize(protocol.maxSavePostSize);
                     processor.setServer(protocol.server);
                     localProcessor.set(processor);
-                    if (protocol.getDomain() != null) {
-                        synchronized (this) {
-                            try {
-                                RequestInfo rp = processor.getRequest().getRequestProcessor();
-                                rp.setGlobalProcessor(global);
-                                ObjectName rpName = new ObjectName
-                                (protocol.getDomain() + ":type=RequestProcessor,worker="
-                                        + protocol.getName() + ",name=HttpRequest" + count++);
-                                Registry.getRegistry(null, null).registerComponent(rp, rpName, null);
-                            } catch (Exception e) {
-                                log.warn("Error registering request");
-                            }
-                        }
-                    }
                 }
 
                 if (processor instanceof ActionHook) {
                     ((ActionHook) processor).action(ActionCode.ACTION_START, null);
                 }
 
-                if (protocol.secure && (protocol.sslImplementation != null)) {
-                    processor.setSSLSupport
-                        (protocol.sslImplementation.getSSLSupport(socket));
-                } else {
-                    processor.setSSLSupport(null);
-                }
-                
                 processor.process(socket);
                 return false;
 
@@ -567,31 +502,8 @@
 
     // *
     protected String domain;
-    protected ObjectName oname;
-    protected MBeanServer mserver;
-
-    public ObjectName getObjectName() {
-        return oname;
-    }
 
     public String getDomain() {
         return domain;
-    }
-
-    public ObjectName preRegister(MBeanServer server,
-                                  ObjectName name) throws Exception {
-        oname=name;
-        mserver=server;
-        domain=name.getDomain();
-        return name;
-    }
-
-    public void postRegister(Boolean registrationDone) {
-    }
-
-    public void preDeregister() throws Exception {
-    }
-
-    public void postDeregister() {
     }
 }

Modified: tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/net/simple/SimpleEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/net/simple/SimpleEndpoint.java?view=diff&rev=442109&r1=442108&r2=442109
==============================================================================
--- tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/net/simple/SimpleEndpoint.java (original)
+++ tomcat/sandbox/tomcat-lite/java/org/apache/tomcat/util/net/simple/SimpleEndpoint.java Sun Sep 10 23:09:56 2006
@@ -23,11 +23,8 @@
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.net.SocketException;
-import java.security.AccessControlException;
 import java.util.ArrayList;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.tomcat.util.net.http11.Endpoint;
 
 
@@ -403,29 +400,28 @@
         Socket accepted = null;
 
     	try {
-    	    accepted = serverSocket.accept();
-            if (null == accepted) {
-                log.warn("Accepted null socket");
-            } else {
-                if (!running) {
+            System.err.println("Before accept");
+            while (running) {
+                try {
+                    accepted = serverSocket.accept();
+                    if (accepted == null) {
+                        System.err.println("Accepted null socket");
+                    }
+                } catch(InterruptedIOException iioe) {
+                    // normal part -- should happen regularly so
+                    // that the endpoint can release if the server
+                    // is shutdown. This will happen every serverTimeout secs.
+                    //System.err.println("INT " + Thread.currentThread());
+                }
+                if (null != accepted) {
+                    return accepted;
+                }
+            } 
+            if (!running) {
                     accepted.close();  // rude, but unlikely!
                     accepted = null;
-                }
             }
-        }
-        catch(InterruptedIOException iioe) {
-            // normal part -- should happen regularly so
-            // that the endpoint can release if the server
-            // is shutdown.
-        }
-        catch (AccessControlException ace) {
-            // When using the Java SecurityManager this exception
-            // can be thrown if you are restricting access to the
-            // socket with SocketPermission's.
-            // Log the unauthorized access and continue
-            log.warn("AccessControlException", ace);
-        }
-        catch (IOException e) {
+        } catch (IOException e) {
 
             if (running) {
                 log.error("IOException", e);
@@ -441,47 +437,52 @@
             }
 
             if( ! running ) return null;
+            
             reinitializing = true;
-            // Restart endpoint when getting an IOException during accept
-            synchronized (threadSync) {
-                if (reinitializing) {
-                    reinitializing = false;
-                    // 1) Attempt to close server socket
-                    closeServerSocket();
-                    initialized = false;
-                    // 2) Reinit endpoint (recreate server socket)
+            reinit();
+        }
+
+        return accepted;
+    }
+
+    private void reinit() throws ThreadDeath {
+        // Restart endpoint when getting an IOException during accept
+        synchronized (threadSync) {
+            if (reinitializing) {
+                reinitializing = false;
+                // 1) Attempt to close server socket
+                closeServerSocket();
+                initialized = false;
+                // 2) Reinit endpoint (recreate server socket)
+                try {
+                    log.warn("Reinit endpoint");
+                    initEndpoint();
+                } catch (Throwable t) {
+                    log.error("Error in reinit", t);
+                }
+                // 3) If failed, attempt to restart endpoint
+                if (!initialized) {
+                    log.warn("Restart endpoint");
                     try {
-                        log.warn("Reinit endpoint");
+                        stopEndpoint();
                         initEndpoint();
+                        startEndpoint();
                     } catch (Throwable t) {
-                        log.error("Error in reinit", t);
-                    }
-                    // 3) If failed, attempt to restart endpoint
-                    if (!initialized) {
-                        log.warn("Restart endpoint");
-                        try {
-                            stopEndpoint();
-                            initEndpoint();
-                            startEndpoint();
-                        } catch (Throwable t) {
-                            log.error("Error in restart", t);
-                        }
-                        // Current thread is now invalid: kill it
-                        throw new ThreadDeath();
+                        log.error("Error in restart", t);
                     }
+                    // Current thread is now invalid: kill it
+                    throw new ThreadDeath();
                 }
             }
-
         }
-
-        return accepted;
     }
 
     public void processSocket(Socket s) {
         // Process the connection
         int step = 1;
         try {
-            
+            System.err.println("process socket " + s);
+            if (s == null) return;
             // 1: Set socket options: timeout, linger, etc
             setSocketOptions(s);
             
@@ -509,7 +510,8 @@
             }
             // Try to close the socket
             try {
-                s.close();
+                if ( s!= null ) 
+                    s.close();
             } catch (IOException e) {
             }
         } finally {
@@ -552,7 +554,7 @@
                 }
                 
                 Socket socket = acceptSocket();
-                
+                System.err.println("Accepted socket " + socket + " " + Thread.currentThread());
                 curThreads++;
                 
                 // Process the request from this socket

Added: tomcat/sandbox/tomcat-lite/resources/deploy.MF
URL: http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-lite/resources/deploy.MF?view=auto&rev=442109
==============================================================================
--- tomcat/sandbox/tomcat-lite/resources/deploy.MF (added)
+++ tomcat/sandbox/tomcat-lite/resources/deploy.MF Sun Sep 10 23:09:56 2006
@@ -0,0 +1,2 @@
+Manifest-version: 1.0
+Main-Class: org.apache.tomcat.servlets.deploy.Main

Propchange: tomcat/sandbox/tomcat-lite/resources/deploy.MF
------------------------------------------------------------------------------
    svn:executable = *



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