billbarker    2004/06/04 22:51:30

  Modified:    jk/java/org/apache/jk/common ChannelSocket.java
  Log:
  Finally remove the default setting of address if not specified.
  
  Also some cleanup of logging levels.
  
  Fix for Bug #39375
  Fix for Bug #29399
  
  Revision  Changes    Path
  1.47      +32 -25    
jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelSocket.java
  
  Index: ChannelSocket.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelSocket.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- ChannelSocket.java        31 May 2004 04:48:54 -0000      1.46
  +++ ChannelSocket.java        5 Jun 2004 05:51:30 -0000       1.47
  @@ -25,6 +25,7 @@
   import java.net.InetAddress;
   import java.net.ServerSocket;
   import java.net.Socket;
  +import java.net.SocketException;
   
   import javax.management.ListenerNotFoundException;
   import javax.management.MBeanNotificationInfo;
  @@ -148,14 +149,14 @@
           try {
               this.inet= InetAddress.getByName( inet );
           } catch( Exception ex ) {
  -            ex.printStackTrace();
  +            log.error("Error parsing "+inet,ex);
           }
       }
   
       public String getAddress() {
           if( inet!=null)
               return inet.toString();
  -        return null;
  +        return "/0.0.0.0";
       }
   
       /**
  @@ -340,11 +341,13 @@
           }
           if (maxPort < startPort)
               maxPort = startPort;
  -        if (getAddress() == null)
  -            setAddress("0.0.0.0");
           for( int i=startPort; i<=maxPort; i++ ) {
               try {
  -                sSocket=new ServerSocket( i, 0, inet );
  +                if( inet == null ) {
  +                    sSocket = new ServerSocket( i, 0 );
  +                } else {
  +                    sSocket=new ServerSocket( i, 0, inet );
  +                }
                   port=i;
                   break;
               } catch( IOException ex ) {
  @@ -447,17 +450,18 @@
       }
   
       private void unLockSocket() throws IOException {
  -     // Need to create a connection to unlock the accept();
  -     Socket s;
  +        // Need to create a connection to unlock the accept();
  +        Socket s;
  +        InetAddress ladr = inet;
  +
  +        if (ladr == null || "0.0.0.0".equals(ladr.getHostAddress())) {
  +            ladr = InetAddress.getLocalHost();
  +        }
  +        s=new Socket(ladr, port );
  +        // setting soLinger to a small value will help shutdown the
  +        // connection quicker
  +        s.setSoLinger(true, 0);
   
  -     if (inet == null || "0.0.0.0".equals(inet.getHostAddress())) {
  -         s=new Socket("127.0.0.1", port );
  -     }else{
  -         s=new Socket(inet, port );
  -         // setting soLinger to a small value will help shutdown the
  -         // connection quicker
  -         s.setSoLinger(true, 0);
  -     }
        s.close();
       }
   
  @@ -590,8 +594,16 @@
           int got;
   
           while(pos < len) {
  -            got = is.read(b, pos + offset, len - pos);
  -
  +            try {
  +                got = is.read(b, pos + offset, len - pos);
  +            } catch(SocketException sex) {
  +                if(pos > 0) {
  +                    log.info("Error reading data after "+pos+"bytes",sex);
  +                } else {
  +                    log.debug("Error reading data", sex);
  +                }
  +                got = -1;
  +            }
               if (log.isTraceEnabled()) {
                   log.trace("read() " + b + " " + (b==null ? 0: b.length) + " " +
                             offset + " " + len + " = " + got );
  @@ -743,16 +755,11 @@
       
       public String getChannelName() {
           String encodedAddr = "";
  -        String address = getAddress();
  -        if (address != null) {
  -            encodedAddr = address;
  +        if (inet != null && !"0.0.0.0".equals(inet.getHostAddress())) {
  +            encodedAddr = getAddress();
               if (encodedAddr.startsWith("/"))
                   encodedAddr = encodedAddr.substring(1);
  -            if("0.0.0.0".equals(encodedAddr)) {
  -                encodedAddr = "";
  -            } else {
  -                encodedAddr = URLEncoder.encode(encodedAddr) + "-";
  -            }
  +         encodedAddr = URLEncoder.encode(encodedAddr) + "-";
           }
           return ("jk-" + encodedAddr + port);
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to