geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject cvs commit: incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol ServerSocketAcceptor.java SocketProtocol.java
Date Sat, 01 May 2004 17:23:55 GMT
adc         2004/05/01 10:23:55

  Modified:    modules/network/src/java/org/apache/geronimo/network/protocol
                        ServerSocketAcceptor.java SocketProtocol.java
  Log:
  When a connection is closed it may remain in a timeout state for a short
  period of time.  In such cases, it is not possible to bind a socket to the
  required address if a previous connection to the same address is in a
  timeout state.
  
  Revision  Changes    Path
  1.7       +21 -10    incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/ServerSocketAcceptor.java
  
  Index: ServerSocketAcceptor.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/ServerSocketAcceptor.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ServerSocketAcceptor.java	25 Apr 2004 02:03:37 -0000	1.6
  +++ ServerSocketAcceptor.java	1 May 2004 17:23:55 -0000	1.7
  @@ -46,7 +46,8 @@
   
       private ServerSocketChannel serverSocketChannel;
       private int timeOut;
  -    private boolean enableTcpNoDelay;
  +    private boolean TCPNoDelay;
  +    private boolean reuseAddress = true;
       private SelectorManager selectorManager;
       private SelectionKey selectionKey;
   
  @@ -88,13 +89,22 @@
           this.timeOut = timeOut;
       }
   
  -    public boolean isEnableTcpNoDelay() {
  -        return enableTcpNoDelay;
  +    public boolean isTCPNoDelay() {
  +        return TCPNoDelay;
       }
   
  -    public void setEnableTcpNoDelay(boolean enableTcpNoDelay) {
  +    public void setTCPNoDelay(boolean TCPNoDelay) {
           if (state == STARTED || state == FAILED) throw new IllegalStateException("Protocol
already started");
  -        this.enableTcpNoDelay = enableTcpNoDelay;
  +        this.TCPNoDelay = TCPNoDelay;
  +    }
  +
  +    public boolean isReuseAddress() {
  +        return reuseAddress;
  +    }
  +
  +    public void setReuseAddress(boolean reuseAddress) {
  +        if (state == STARTED || state == FAILED) throw new IllegalStateException("Protocol
already started");
  +        this.reuseAddress = reuseAddress;
       }
   
       public ServerSocketAcceptorListener getAcceptorListener() {
  @@ -119,13 +129,14 @@
           String serverBindAddress = uri.getHost();
           int serverBindPort = uri.getPort();
           int connectBackLog = 50;
  -        enableTcpNoDelay = true;
  +        TCPNoDelay = true;
   
           Properties params = URISupport.parseQueryParameters(uri);
  -        enableTcpNoDelay = params.getProperty("tcp.nodelay", "true").equals("true");
  +        TCPNoDelay = params.getProperty("tcp.nodelay", "true").equals("true");
           connectBackLog = Integer.parseInt(params.getProperty("tcp.backlog", "50"));
   
           serverSocketChannel = ServerSocketChannel.open();
  +        serverSocketChannel.socket().setReuseAddress(reuseAddress);
           serverSocketChannel.socket().bind(new InetSocketAddress(InetAddress.getByName(serverBindAddress),
serverBindPort), connectBackLog);
           serverSocketChannel.socket().setSoTimeout(timeOut);
           serverSocketChannel.configureBlocking(false);
  @@ -133,7 +144,7 @@
   
           // Create the client URI:
           Properties clientParms = new Properties();
  -        clientParms.put("tcp.nodelay", enableTcpNoDelay ? "true" : "false");
  +        clientParms.put("tcp.nodelay", TCPNoDelay ? "true" : "false");
           connectURI = new URI("async",
                                null,
                                InetAddress.getByName(serverBindAddress).getHostName(),
  @@ -168,7 +179,7 @@
   
                   if (channel == null) return;
   
  -                channel.socket().setTcpNoDelay(enableTcpNoDelay);
  +                channel.socket().setTcpNoDelay(TCPNoDelay);
                   acceptorListener.accept(channel);
   
                   selectorManager.addInterestOps(selectionKey, SelectionKey.OP_ACCEPT);
  
  
  
  1.11      +23 -3     incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/SocketProtocol.java
  
  Index: SocketProtocol.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/SocketProtocol.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SocketProtocol.java	25 Apr 2004 02:03:37 -0000	1.10
  +++ SocketProtocol.java	1 May 2004 17:23:55 -0000	1.11
  @@ -50,6 +50,8 @@
       private SocketAddress socketInterface;
   
       private long timeout;
  +    private boolean TCPNoDelay;
  +    private boolean reuseAddress = true;
       private Mutex sendMutex;
       private SelectorManager selectorManager;
       private SelectionKey selectionKey;
  @@ -129,6 +131,24 @@
           this.timeout = timeout;
       }
   
  +    public boolean isTCPNoDelay() {
  +        return TCPNoDelay;
  +    }
  +
  +    public void setTCPNoDelay(boolean TCPNoDelay) {
  +        if (state == STARTED) throw new IllegalStateException("Protocol already started");
  +        this.TCPNoDelay = TCPNoDelay;
  +    }
  +
  +    public boolean isReuseAddress() {
  +        if (state == STARTED) throw new IllegalStateException("Protocol already started");
  +        return reuseAddress;
  +    }
  +
  +    public void setReuseAddress(boolean reuseAddress) {
  +        this.reuseAddress = reuseAddress;
  +    }
  +
       public SelectorManager getSelectorManager() {
           return selectorManager;
       }
  @@ -170,9 +190,9 @@
               try {
                   socketChannel = SocketChannel.open();
                   socketChannel.configureBlocking(true);
  +                socketChannel.socket().setReuseAddress(reuseAddress);
  +                socketChannel.socket().setTcpNoDelay(TCPNoDelay);
                   if (socketInterface != null) socketChannel.socket().bind(socketInterface);
  -                socketChannel.socket().setReuseAddress(true);
  -                socketChannel.socket().setTcpNoDelay(true);
                   socketChannel.connect(address);
               } catch (SocketException e) {
                   state = STOPPED;
  
  
  

Mime
View raw message