apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <trawi...@bellsouth.net>
Subject Re: cvs commit: apr/test client.c server.c
Date Tue, 21 Nov 2000 21:44:32 GMT
Greg Stein <gstein@lyra.org> writes:

> On Tue, Nov 21, 2000 at 07:15:32PM -0000, trawick@locus.apache.org wrote:
> > trawick     00/11/21 11:15:30
> > 
> >   Modified:    test     client.c server.c
> >   Log:
> >   updates to changed interfaces to apr_set_port(), apr_get_port(),
> >   apr_set_ipaddr(), and apr_get_ipaddr()
> >...
> >   --- server.c	2000/11/19 14:24:18	1.20
> >   +++ server.c	2000/11/21 19:15:27	1.21
> >   @@ -73,7 +73,7 @@
> >        const char *bind_to_ipaddr = NULL;
> >        char *local_ipaddr, *remote_ipaddr;
> >        apr_port_t local_port, remote_port;
> >   -    apr_sockaddr_t *localsa = NULL;
> >   +    apr_sockaddr_t *localsa = NULL, *remotesa;
> >        apr_status_t stat;
> >        int family = APR_UNSPEC;
> >        char buf[128];
> >   @@ -155,8 +155,8 @@
> >        fprintf(stdout, "OK\n");
> >    
> >        if (!localsa) {
> >   -        apr_set_port(sock, APR_LOCAL, 8021);
> >            apr_get_sockaddr(&localsa, APR_LOCAL, sock);
> >   +        apr_set_port(localsa, 8021);
> >        }
> 
> This seems a bit wonky. The above code implies that an apr_get_sockaddr()
> returns an address that is *attached* to the socket. That any changes to the
> address will reflect within the socket.

yep...

> That seems like it will introduce a number of subtle bugs.
> 
> - if people forget the attached state
> - what happens when it gets passed elsewhere
> - can it be used after the socket closes

no

> - etc

Well, the obvious alternative is to copy, but I'm not sure how many
copies of these things we'd end up with if apps aren't careful.

Perhaps a way to *copy* the sockaddr out of the socket could be
provided for apps that want to create an independent sockaddr which
looks like one of the sockaddrs associated with the socket but which
has an independent lifetime?

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

Mime
View raw message