avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/services/connection AbstractService.java
Date Fri, 26 Apr 2002 07:38:52 GMT
colus       02/04/26 00:38:52

  Modified:    src/java/org/apache/avalon/cornerstone/services/connection
                        AbstractService.java
  Log:
  Close server socket when disposing.
  
  Revision  Changes    Path
  1.9       +17 -7     jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/services/connection/AbstractService.java
  
  Index: AbstractService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/services/connection/AbstractService.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AbstractService.java	16 Mar 2002 00:18:35 -0000	1.8
  +++ AbstractService.java	26 Apr 2002 07:38:52 -0000	1.9
  @@ -9,6 +9,7 @@
   
   import java.net.InetAddress;
   import java.net.ServerSocket;
  +import java.io.IOException;
   import org.apache.avalon.cornerstone.services.sockets.ServerSocketFactory;
   import org.apache.avalon.cornerstone.services.sockets.SocketManager;
   import org.apache.avalon.excalibur.thread.ThreadPool;
  @@ -44,6 +45,7 @@
       protected String m_serverSocketType;
       protected int m_port;
       protected InetAddress m_bindTo; //network interface to bind to
  +    protected ServerSocket m_serverSocket;
       protected String m_connectionName;
   
       public AbstractService()
  @@ -130,25 +132,24 @@
           final ServerSocketFactory factory =
               m_socketManager.getServerSocketFactory( m_serverSocketType );
   
  -        ServerSocket serverSocket = null;
  -
           if( null == m_bindTo )
           {
  -            serverSocket = factory.createServerSocket( m_port );
  +            m_serverSocket = factory.createServerSocket( m_port );
           }
           else
           {
  -            serverSocket = factory.createServerSocket( m_port, 5, m_bindTo );
  +            m_serverSocket = factory.createServerSocket( m_port, 5, m_bindTo );
           }
   
           if( null == m_threadPool )
           {
  -            m_connectionManager.connect( m_connectionName, serverSocket, m_factory );
  +            m_connectionManager.connect( m_connectionName, m_serverSocket,
  +                                         m_factory );
           }
           else
           {
  -            m_connectionManager.
  -                connect( m_connectionName, serverSocket, m_factory, m_threadPool );
  +            m_connectionManager.connect( m_connectionName, m_serverSocket,
  +                                         m_factory, m_threadPool );
           }
       }
   
  @@ -161,6 +162,15 @@
           catch( final Exception e )
           {
               getLogger().warn( "Error disconnecting", e );
  +        }
  +
  +        try
  +        {
  +            m_serverSocket.close();
  +        }
  +        catch( final IOException ioe )
  +        {
  +            getLogger().warn( "Error closing server socket", ioe );
           }
       }
   }
  
  
  

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


Mime
View raw message