tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java
Date Sat, 16 Jul 2005 12:11:12 GMT
mturk       2005/07/16 05:11:11

  Modified:    util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Add APR_SO_REUSEADDR and APR_SO_KEEPALIVE to the listening
  socket. This resolves 'address in use exception', and is the way how
  the Apache HTTPD is using the APR.
  See the: server/listen.c
  
  Revision  Changes    Path
  1.66      +8 -0      jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/AprEndpoint.java
  
  Index: AprEndpoint.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/AprEndpoint.java,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- AprEndpoint.java	15 Jul 2005 15:40:00 -0000	1.65
  +++ AprEndpoint.java	16 Jul 2005 12:11:11 -0000	1.66
  @@ -24,6 +24,7 @@
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +import org.apache.tomcat.jni.OS;
   import org.apache.tomcat.jni.Address;
   import org.apache.tomcat.jni.Error;
   import org.apache.tomcat.jni.File;
  @@ -511,6 +512,9 @@
           // Create the APR server socket
           serverSock = Socket.create(Socket.APR_INET, Socket.SOCK_STREAM,
                   Socket.APR_PROTO_TCP, rootPool);
  +        if (OS.IS_UNIX) {
  +            Socket.optSet(serverSock, Socket.APR_SO_REUSEADDR, 1);    
  +        }
           // Bind the server socket
           int ret = Socket.bind(serverSock, inetAddress);
           if (ret != 0) {
  @@ -521,6 +525,10 @@
           if (ret != 0) {
               throw new Exception(sm.getString("endpoint.init.listen", "" + ret));
           }
  +        if (OS.IS_WIN32 || OS.IS_WIN64) {
  +            // On Windows set the reuseaddr flag after the bind/listen
  +            Socket.optSet(serverSock, Socket.APR_SO_REUSEADDR, 1);    
  +        }
   
           // Sendfile usage on systems which don't support it cause major problems
           if (useSendfile && !Library.APR_HAS_SENDFILE) {
  
  
  

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


Mime
View raw message