You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Gregory Nicholls <gn...@level8.com> on 2000/07/25 16:16:17 UTC

ap_connect ???

 Hiya,
    The comments in the header for ap_connect seem to permit a hostname parameter
of NULL. I tried this and received an abend. Looking at the source for ap_connect,
there doesn't seem to be any checks for NULL so I'm wondering if the comments are
wrong, the code is wrong, my version is outdated or I'm just thick. I'm using
2.0a4 base with no mods (CVS-challenged I'm afraid).
    Thanks,
        G.


Re: ap_connect - part 2

Posted by Gregory Nicholls <gn...@level8.com>.
 OK I'll give it a whirl. For the record I'm CVS ignorant and barely Unix literate (old MF guy I'm
afraid). I'll take a stab at it and we can all have a good laugh at the results.
    G.
(who's now off to see if he can get CVS working ....)

Jeff Trawick wrote:

> Gregory Nicholls <gn...@level8.com> writes:
>
> >   While you're in there could you check something else for me plz ??  I was attempting a
> > bind to port 0 and then trying to use get_local_port to retrieve the port that is
> > (theoretically) assigned. Now this (again Win32 only) didn't work. It returned port 0. The
> > code for this function is:
> >
> >     *port = ntohs(sock->local_addr->sin_port);
> >     return APR_SUCCESS;
> >
> > in sockaddr.c.
> >
> >     Now I don't know if I'm interpreting the function's purpose correctly however I think it
> > needs a getsockname() call somewhere along the line . . .
> >
> >     G.
>
> Yes sir, that is correct.  A getsockname() call could be added after
> bind() (and connect() for that matter), or
> getsockname-deferral/avoidance logic (like in the
> lib/apr/network_io/unix code) could be implemented in the Win32 path.
> Either method is simple to implement.  Do you want to handle this and
> post the patch?  It looks like you're in a position to test it.  I
> don't have time in the short term.
>
> I'd recommend getting your anonymous cvs access working first so that
> you can use the output of "cvs diff -u filename ..." as the patch to
> post to the list when you get it working.
>
> --
> Jeff Trawick | trawick@ibm.net | PGP public key at web site:
>      http://www.geocities.com/SiliconValley/Park/9289/
>           Born in Roswell... married an alien...


Re: ap_connect - part 2

Posted by Jeff Trawick <tr...@bellsouth.net>.
Gregory Nicholls <gn...@level8.com> writes:

>   While you're in there could you check something else for me plz ??  I was attempting a
> bind to port 0 and then trying to use get_local_port to retrieve the port that is
> (theoretically) assigned. Now this (again Win32 only) didn't work. It returned port 0. The
> code for this function is:
> 
>     *port = ntohs(sock->local_addr->sin_port);
>     return APR_SUCCESS;
> 
> in sockaddr.c.
> 
>     Now I don't know if I'm interpreting the function's purpose correctly however I think it
> needs a getsockname() call somewhere along the line . . .
> 
>     G.

Yes sir, that is correct.  A getsockname() call could be added after
bind() (and connect() for that matter), or
getsockname-deferral/avoidance logic (like in the
lib/apr/network_io/unix code) could be implemented in the Win32 path.
Either method is simple to implement.  Do you want to handle this and 
post the patch?  It looks like you're in a position to test it.  I
don't have time in the short term.

I'd recommend getting your anonymous cvs access working first so that
you can use the output of "cvs diff -u filename ..." as the patch to
post to the list when you get it working.

-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

ap_connect - part 2

Posted by Gregory Nicholls <gn...@level8.com>.
  Jeff Trawick wrote:

> Ahh... Silly me... I was looking in the Unix code.  Sorry!  I'll put
> in the trivial change to the win32 version so that it works like the Unix code.
>

  While you're in there could you check something else for me plz ??  I was attempting a
bind to port 0 and then trying to use get_local_port to retrieve the port that is
(theoretically) assigned. Now this (again Win32 only) didn't work. It returned port 0. The
code for this function is:

    *port = ntohs(sock->local_addr->sin_port);
    return APR_SUCCESS;

in sockaddr.c.

    Now I don't know if I'm interpreting the function's purpose correctly however I think it
needs a getsockname() call somewhere along the line . . .

    G.


Re: ap_connect ???

Posted by Jeff Trawick <tr...@bellsouth.net>.
Gregory Nicholls <gn...@level8.com> writes:

>     Here's a cutout of the connect code in the version I'm using. It blew up trying to
> check *hostname.
> Obviously since it's NULL this isn't good. This was on line 195 of sockets.c in the
> Win32 version.

Ahh... Silly me... I was looking in the Unix code.  Sorry!  I'll put
in the trivial change to the win32 version so that it works like the Unix code.

-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Re: ap_connect ???

Posted by Gregory Nicholls <gn...@level8.com>.
  Hi,
        I'd created the socket, set the remote port and remoteaddr (127.0.0.1) and then
issued the connect a la ap_connect(sock,NULL).
    Here's a cutout of the connect code in the version I'm using. It blew up trying to
check *hostname.
Obviously since it's NULL this isn't good. This was on line 195 of sockets.c in the
Win32 version.
I'll keep playing with it until I find the correct incantation.
    G.

--------------------------- cut here -----------------------------------------------
    if ((sock->sock == INVALID_SOCKET) || (!sock->local_addr)) {
        return APR_ENOTSOCK;
    }

    if (*hostname >= '0' && *hostname <= '9' &&
        strspn(hostname, "0123456789.") == strlen(hostname)) {
        sock->remote_addr->sin_addr.s_addr = inet_addr(hostname);
    }
------------------------------------------------------------------------------------

Jeff Trawick wrote:

> Gregory Nicholls <gn...@level8.com> writes:
>
> >  Hiya,
> >     The comments in the header for ap_connect seem to permit a hostname parameter
> > of NULL. I tried this and received an abend. Looking at the source for ap_connect,
> > there doesn't seem to be any checks for NULL so I'm wondering if the comments are
> > wrong, the code is wrong, my version is outdated or I'm just thick. I'm using
> > 2.0a4 base with no mods (CVS-challenged I'm afraid).
> >     Thanks,
> >         G.
>
> What operations had you done on the ap_socket_t prior to ap_connect()?
> One what line did you abend?  I don't see a friendly way in the API to
> set the target address other than with ap_connect(), but I don't see
> why ap_connect() should abend either.  The current ap_connect() does
> avoid some processing if the 2nd parm is NULL; it assumes that the remote
> address in the ap_socket_t has already been set.
>
> About CVS...  Follow the instructions at
> http://dev.apache.org/anoncvs.txt.  It is really easy and quite cool.
>
> --
> Jeff Trawick | trawick@ibm.net | PGP public key at web site:
>      http://www.geocities.com/SiliconValley/Park/9289/
>           Born in Roswell... married an alien...


Re: ap_connect ???

Posted by Jeff Trawick <tr...@bellsouth.net>.
Gregory Nicholls <gn...@level8.com> writes:

>  Hiya,
>     The comments in the header for ap_connect seem to permit a hostname parameter
> of NULL. I tried this and received an abend. Looking at the source for ap_connect,
> there doesn't seem to be any checks for NULL so I'm wondering if the comments are
> wrong, the code is wrong, my version is outdated or I'm just thick. I'm using
> 2.0a4 base with no mods (CVS-challenged I'm afraid).
>     Thanks,
>         G.

What operations had you done on the ap_socket_t prior to ap_connect()?
One what line did you abend?  I don't see a friendly way in the API to
set the target address other than with ap_connect(), but I don't see
why ap_connect() should abend either.  The current ap_connect() does
avoid some processing if the 2nd parm is NULL; it assumes that the remote
address in the ap_socket_t has already been set.

About CVS...  Follow the instructions at
http://dev.apache.org/anoncvs.txt.  It is really easy and quite cool.

-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Re: ap_connect ???

Posted by rb...@covalent.net.
It is likely that the comments are for a previous version.  Unfortunately,
the docs have not been keeping up with the code recently.  I am trying to
stay on top of the docs, but I'm not succeeding.  The best I can suggest
is if you see a problem with the docs, make a patch to fix them, or send a
note here (like you did  :-) and we'll try to fix it ASAP.

Ryan

On Tue, 25 Jul 2000, Gregory Nicholls wrote:

>  Hiya,
>     The comments in the header for ap_connect seem to permit a hostname parameter
> of NULL. I tried this and received an abend. Looking at the source for ap_connect,
> there doesn't seem to be any checks for NULL so I'm wondering if the comments are
> wrong, the code is wrong, my version is outdated or I'm just thick. I'm using
> 2.0a4 base with no mods (CVS-challenged I'm afraid).
>     Thanks,
>         G.
> 


_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------