www-apache-bugdb mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akful...@august.com (Andrew Fullford)
Subject Re: mod_jserv/4340: socket connection to jserv should be bound to host address
Date Fri, 21 May 1999 23:20:00 GMT
The following reply was made to PR mod_jserv/4340; it has been noted by GNATS.

From: akfullfo@august.com (Andrew Fullford)
To: jon@clearink.com
Cc: apbugs@hyperreal.org, java-apache@list.working-dogs.com
Subject: Re: mod_jserv/4340: socket connection to jserv should be bound to host address
Date: Fri, 21 May 1999 18:19:14 -0500 (CDT)

 Jon,
 
 I finally got a chance to examine this further.  I believe the problem
 is that "addr" here is specifying both the IP and the port, but we
 actually must only specify the IP address, as the port is guaranteed to
 be in use (by the JServ listener).
 
 So, instead of:
 
    ret=bind(sock,(struct sockaddr *)&addr,sizeof(struct sockaddr_in));
 
 We really need something more like:
 
    {
 	struct sockaddr_in local = addr;
 	local.sin_port = htons(0);
 	ret=bind(sock,(struct sockaddr *)&local,sizeof(struct sockaddr_in));
 	if (ret==-1) {
 	      .  .  .
 	}
    }
 
 I'd supply some actual diffs here, but it turns out there is a further
 complication.  As written, org.apache.jserv.JServ doesn't appear to
 have any way to listen on other than INADDR_ANY (aka 0.0.0.0).
 
 This means that you can't currently run more than one JServ on the same
 port but a different virtual interfaces.  So this gets to be much more
 like an enhancement than a bug fix.  As far as I can see, we'd need
 to:
 
 	- add a new property (say "host") so the listen address can
 	  be specified.
 
 	- change AuthenticatedServerSocket.java to use the 3 arg version
 	  of ServerSocket() if this property is specified, otherwise
 	  the current 2 arg version.
 
 As the whole point of the jserv_ajpv11.c change is to allow operation
 on specific addresses when a host runs multiple interfaces, the java
 changes would have to happen as well.
 
 I'm not sure what priority you guys place on this or if anyone else has
 run into this kind of thing.  Certainly it would make my life easier
 but I can achieve nearly the same thing by allocating separate ports
 for each JServ running on a virtual interface.
 
 I'm happy to help out but my java abilities are a good deal worse than
 my C abilities!
 
 Andy
 --
 Andrew Fullford       Email: andy@august.net
 August Associates        Web: www.august.net
 
 > Date: Mon, 10 May 1999 19:46:13 -0700
 > Subject: Re: mod_jserv/4340: socket connection to jserv should be bound to
 > 	 host address
 > From: "jon *" <jon@clearink.com>
 > To: akfullfo@august.com
 > CC: apbugs@hyperreal.org, java-apache@list.working-dogs.com
 > 
 > >    ret=bind(sock,(struct sockaddr *)&addr,sizeof(struct sockaddr_in));
 > 
 > Hello,
 > 
 > I have tried adding that line and everything stopped working...the diff of
 > the code change that I attempted is below. I do see the cannot bind to host
 > error in my mod_jserv.log file.
 > 
 > I really am not experienced with networking code in C so I'm not sure what
 > is going wrong, I'm just trying to see if I can close this bug report.
 > 
 > Any better ideas?
 > 
 > -jon
 > 
 > Index: jserv_ajpv11.c
 > ===================================================================
 > RCS file: /products/cvs/master/jserv/src/c/jserv_ajpv11.c,v
 > retrieving revision 1.24
 > diff -r1.24 jserv_ajpv11.c
 > 101a102,110
 > >     ret=bind(sock,(struct sockaddr *)&addr,sizeof(struct sockaddr_in));
 > >     if (ret==-1) {
 > >         jserv_error(JSERV_LOG_EMERG,cfg,"ajp11: %s %s:%d",
 > >                     "can not bind to host",
 > >                     inet_ntoa(addr.sin_addr),
 > >                     port);
 > >         return -1;
 > >     }
 > > 
 > 

Mime
View raw message