apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Morgan <rmor...@covalent.net>
Subject Re: [patch] apr_sockaddr_port_get broken
Date Fri, 05 Apr 2002 21:59:07 GMT
On Fri, Apr 05, 2002 at 04:42:33PM -0500, Jeff Trawick wrote:
> Ryan Morgan <rmorgan@covalent.net> writes:
> 
> > The cleanup of the unix networking code a while back has broken 
> > apr_sockaddr_port_get when 0 is specifed as the port to bind() to.  This
> > is because we now grab the port from sockaddr->port rather than the
> > actual sockaddr.  (sockaddr->port is never updated after 
> > apr_sockaddr_port_set is called).
> 
> I would think that the better fix is to update sockaddr->port.
> 
> Can you try this instead (need win32 and os/2 flavors as well :( )?

Ah, much better.  That fixes the problem for me.  (And should fix win32
and os/2 since they all use the same apr_socket_addr_get, correct?)

-Ryan

> 
> (I can't play for a few hours.)
> 
> Index: srclib/apr/network_io/unix/sockaddr.c
> ===================================================================
> RCS file: /home/cvs/apr/network_io/unix/sockaddr.c,v
> retrieving revision 1.28
> diff -u -r1.28 sockaddr.c
> --- srclib/apr/network_io/unix/sockaddr.c       13 Mar 2002 20:39:25
> -0000      1.28
> +++ srclib/apr/network_io/unix/sockaddr.c       5 Apr 2002 21:44:21
> -0000
> @@ -64,6 +64,8 @@
>      }
>      else {
>          sock->local_port_unknown = sock->local_interface_unknown = 0;
> +        /* XXX assumes sin_port and sin6_port at same offset */
> +        sock->local_addr->port = ntohs(sock->local_addr->sa.sin.sin_port);
>          return APR_SUCCESS;
>      }
>  }
> 
> -- 
> Jeff Trawick | trawick@attglobal.net
> Born in Roswell... married an alien...

Mime
View raw message