You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@apache.org on 2001/04/10 00:59:29 UTC

cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http HttpConnector.java HttpProcessor.java

craigmcc    01/04/09 15:59:29

  Modified:    catalina/src/share/org/apache/catalina/connector/http
                        HttpConnector.java HttpProcessor.java
  Log:
  Rearrange how shutdown occurs so that trying to reopen the server socket
  (inside the IOException catch in run()) does not throw
  NullPointerException.
  
  Add some debugging logging that is commented out (so that it won't impact
  performance) but can be easily uncommented when investigating specific
  issues.
  
  Revision  Changes    Path
  1.11      +44 -10    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpConnector.java
  
  Index: HttpConnector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpConnector.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- HttpConnector.java	2001/03/31 15:22:11	1.10
  +++ HttpConnector.java	2001/04/09 22:59:29	1.11
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpConnector.java,v 1.10 2001/03/31 15:22:11 glenn Exp $
  - * $Revision: 1.10 $
  - * $Date: 2001/03/31 15:22:11 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpConnector.java,v 1.11 2001/04/09 22:59:29 craigmcc Exp $
  + * $Revision: 1.11 $
  + * $Date: 2001/04/09 22:59:29 $
    *
    * ====================================================================
    *
  @@ -95,7 +95,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.10 $ $Date: 2001/03/31 15:22:11 $
  + * @version $Revision: 1.11 $ $Date: 2001/04/09 22:59:29 $
    */
   
   
  @@ -602,6 +602,8 @@
        */
       public Request createRequest() {
   
  +        //        if (debug >= 2)
  +        //            log("createRequest: Creating new request");
   	HttpRequestImpl request = new HttpRequestImpl();
   	request.setConnector(this);
   	return (request);
  @@ -615,6 +617,8 @@
        */
       public Response createResponse() {
   
  +        //        if (debug >= 2)
  +        //            log("createResponse: Creating new response");
   	HttpResponseImpl response = new HttpResponseImpl();
   	response.setConnector(this);
   	return (response);
  @@ -632,6 +636,8 @@
        */
       void recycle(HttpProcessor processor) {
   
  +        //        if (debug >= 2)
  +        //            log("recycle: Recycling processor " + processor);
           processors.push(processor);
   
       }
  @@ -649,12 +655,20 @@
       private HttpProcessor createProcessor() {
   
   	synchronized (processors) {
  -	    if (processors.size() > 0)
  +	    if (processors.size() > 0) {
  +                //                if (debug >= 2)
  +                //                    log("createProcessor: Reusing existing processor");
   		return ((HttpProcessor) processors.pop());
  -	    if ((maxProcessors > 0) && (curProcessors < maxProcessors))
  +            }
  +	    if ((maxProcessors > 0) && (curProcessors < maxProcessors)) {
  +                //                if (debug >= 2)
  +                //                    log("createProcessor: Creating new processor");
   	        return (newProcessor());
  -	    else
  +            } else {
  +                //                if (debug >= 2)
  +                //                    log("createProcessor: Cannot create new processor");
   	        return (null);
  +            }
   	}
   
       }
  @@ -701,6 +715,8 @@
        */
       private HttpProcessor newProcessor() {
   
  +        //        if (debug >= 2)
  +        //            log("newProcessor: Creating new processor");
           HttpProcessor processor = new HttpProcessor(this, curProcessors++);
   	if (processor instanceof Lifecycle) {
   	    try {
  @@ -762,18 +778,32 @@
   	    // Accept the next incoming connection from the server socket
   	    Socket socket = null;
   	    try {
  +                //                if (debug >= 3)
  +                //                    log("run: Waiting on serverSocket.accept()");
   		socket = serverSocket.accept();
  +                //                if (debug >= 3)
  +                //                    log("run: Returned from serverSocket.accept()");
                   if (connectionTimeout > 0)
                       socket.setSoTimeout(connectionTimeout);
               } catch (AccessControlException ace) {
  -                log("socket accept security exception: " + ace.getMessage());
  +                log("socket accept security exception", ace);
                   continue;
   	    } catch (IOException e) {
  +                //                if (debug >= 3)
  +                //                    log("run: Accept returned IOException", e);
   		if (started && !stopped)
   		    log("accept: ", e);
   		try {
  +                    //                    if (debug >= 3)
  +                    //                        log("run: Closing server socket");
                       serverSocket.close();
  -                    serverSocket = open();
  +                    if (!stopped) {
  +                        //                        if (debug >= 3)
  +                        //                            log("run: Reopening server socket");
  +                        serverSocket = open();
  +                    }
  +                    //                    if (debug >= 3)
  +                    //                        log("run: IOException processing completed");
                   } catch (IOException ex) {
                       // If reopening fails, exit
                       log("socket reopen: ", ex);
  @@ -793,6 +823,8 @@
   		}
   		continue;
   	    }
  +            //            if (debug >= 3)
  +            //                log("run: Assigning socket to processor " + processor);
   	    processor.assign(socket);
   
   	    // The processor will recycle itself when it finishes
  @@ -800,6 +832,8 @@
   	}
   
   	// Notify the threadStop() method that we have shut ourselves down
  +        //        if (debug >= 3)
  +        //            log("run: Notifying threadStop() that we have shut down");
   	synchronized (threadSync) {
   	    threadSync.notifyAll();
   	}
  @@ -937,11 +971,11 @@
   	    } catch (IOException e) {
   		;
   	    }
  -	    serverSocket = null;
   	}
   
   	// Stop our background thread
   	threadStop();
  +        serverSocket = null;
   
       }
   
  
  
  
  1.23      +17 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpProcessor.java
  
  Index: HttpProcessor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpProcessor.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- HttpProcessor.java	2001/03/17 05:32:37	1.22
  +++ HttpProcessor.java	2001/04/09 22:59:29	1.23
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpProcessor.java,v 1.22 2001/03/17 05:32:37 remm Exp $
  - * $Revision: 1.22 $
  - * $Date: 2001/03/17 05:32:37 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpProcessor.java,v 1.23 2001/04/09 22:59:29 craigmcc Exp $
  + * $Revision: 1.23 $
  + * $Date: 2001/04/09 22:59:29 $
    *
    * ====================================================================
    *
  @@ -107,7 +107,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.22 $ $Date: 2001/03/17 05:32:37 $
  + * @version $Revision: 1.23 $ $Date: 2001/04/09 22:59:29 $
    */
   
   final class HttpProcessor
  @@ -289,6 +289,19 @@
        * Request line buffer.
        */
       private HttpRequestLine requestLine = new HttpRequestLine();
  +
  +
  +    // --------------------------------------------------------- Public Methods
  +
  +
  +    /**
  +     * Return a String value representing this object.
  +     */
  +    public String toString() {
  +
  +        return (this.threadName);
  +
  +    }
   
   
       // -------------------------------------------------------- Package Methods