tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net PoolTcpEndpoint.java
Date Thu, 19 Dec 2002 15:55:46 GMT
costin      2002/12/19 07:55:46

  Modified:    util/java/org/apache/tomcat/util/net PoolTcpEndpoint.java
  Log:
  Fix from Michael ( with strange email address ).
  Declare the "running" as volatile and some code cleanups.
  
  Revision  Changes    Path
  1.10      +39 -44    jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/PoolTcpEndpoint.java
  
  Index: PoolTcpEndpoint.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/PoolTcpEndpoint.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- PoolTcpEndpoint.java	19 Dec 2002 05:31:46 -0000	1.9
  +++ PoolTcpEndpoint.java	19 Dec 2002 15:55:45 -0000	1.10
  @@ -120,7 +120,7 @@
       private ServerSocket serverSocket;
   
       ThreadPoolRunnable listener;
  -    private boolean running = false;
  +    private volatile boolean running = false;
       private boolean initialized = false;
       static final int debug=0;
   
  @@ -338,40 +338,35 @@
       // -------------------- Private methods
   
       Socket acceptSocket() {
  +        if( !running || serverSocket==null ) return null;
  +
           Socket accepted = null;
   
       	try {
  -    	    if (running) {
  -		if(null!= serverSocket) {
  -                     if(factory==null){
  - 		        accepted = serverSocket.accept();
  - 		    }
  - 		    else {
  - 		        accepted = factory.acceptSocket(serverSocket);
  - 		    }
  -		    if(!running) {
  -			if(null != accepted) {
  -			    accepted.close();  // rude, but unlikely!
  -			    accepted = null;
  -			}
  -		    }
  -		    if( factory != null && accepted != null)
  -			factory.initSocket( accepted );
  -    	        }
  -    	    }
  -    	}
  -	catch(InterruptedIOException iioe) {
  -    	    // normal part -- should happen regularly so
  -    	    // that the endpoint can release if the server
  -    	    // is shutdown.
  -    	}
  -	catch (IOException e) {
  -
  -    	    if (running) {
  -
  -		String msg = sm.getString("endpoint.err.nonfatal",
  -					  serverSocket, e);
  -		log.error(msg, e);
  +            if(factory==null) {
  +                accepted = serverSocket.accept();
  +            } else {
  +                accepted = factory.acceptSocket(serverSocket);
  +            }
  +            if(!running && (null != accepted)) {
  +                    accepted.close();  // rude, but unlikely!
  +                    accepted = null;
  +            }
  +            if( factory != null && accepted != null)
  +                factory.initSocket( accepted );
  +        }
  +        catch(InterruptedIOException iioe) {
  +            // normal part -- should happen regularly so
  +            // that the endpoint can release if the server
  +            // is shutdown.
  +        }
  +        catch (IOException e) {
  +
  +            if (running) {
  +
  +                String msg = sm.getString("endpoint.err.nonfatal",
  +                        serverSocket, e);
  +                log.error(msg, e);
   
                   if (accepted != null) {
                       try {
  @@ -379,7 +374,7 @@
                           accepted = null;
                       } catch(Exception ex) {
                           msg = sm.getString("endpoint.err.nonfatal",
  -                                           accepted, ex);
  +                                accepted, ex);
                           log.warn(msg, ex);
                       }
                   }
  @@ -389,7 +384,7 @@
                           serverSocket.close();
                       } catch(Exception ex) {
                           msg = sm.getString("endpoint.err.nonfatal",
  -                                           serverSocket, ex);
  +                                serverSocket, ex);
                           log.warn(msg, ex);
                       }
                       serverSocket = null;
  @@ -397,14 +392,14 @@
                           if (inet == null) {
                               serverSocket = factory.createSocket(port, backlog);
                           } else {
  -                            serverSocket = 
  -                                factory.createSocket(port, backlog, inet);
  +                            serverSocket =
  +                                    factory.createSocket(port, backlog, inet);
                           }
                           if (serverTimeout >= 0)
                               serverSocket.setSoTimeout(serverTimeout);
                       } catch (Throwable t) {
  -                        msg = sm.getString("endpoint.err.fatal", 
  -                                           serverSocket, t);
  +                        msg = sm.getString("endpoint.err.fatal",
  +                                serverSocket, t);
                           log.error(msg, t);
                           stopEndpoint();
                       }
  @@ -412,9 +407,9 @@
   
               }
   
  -    	}
  -	
  -    	return accepted;
  +        }
  +
  +        return accepted;
       }
   
       /** @deprecated
  
  
  

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


Mime
View raw message