apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@attglobal.net>
Subject Re: [PATCH] Add support for Unix domain sockets
Date Sat, 05 Jan 2002 01:49:59 GMT
Justin Erenkrantz <jerenkrantz@ebuilt.com> writes:

> Please review.  This attempts to add support for Unix domain
> sockets in APR (call APR_UNIX as the socket type).  I believe 
> Win32 has Unix domain socket support, but I'm not sure.

Cygwin sort-of does, but they seem to use an AF_INET socket.  I do
getsockname() after a bind to /tmp/aaa and it says I have an inet
socket on 127.0.0.1:3180 :)  getsockname() doesn't even work until I
bind().  Their SUN_LEN() macro looks seriously broken too :)

I'm pretty sure that native Win32 does not have AF_UNIX, but then what
would they need it for.  You could argue that APR could have a common
API which on Unix might use AF_UNIX sockets and on Win32 might use
named pipes.  I don't know what that API would be, though.

> This is needed for EGD support.

not really...  You don't need this to do AF_UNIX sockets inside APR.
A pure socket interface will avoid the pool issue too.

If APR "should" have an interface to AF_UNIX sockets, that's fine, but
that has been unclear.

> +#if APR_HAVE_UNIX_DOMAIN
> +#define APR_UNIX     AF_UNIX
> +#endif

Note that POSIX supposedly prefers AF_LOCAL to AF_UNIX.  But we
already have APR_LOCAL :)  (What about APR_SOCKET_INET,
APR_SOCKET_INET6, APR_SOCKET_LOCAL?  Or better yet, AF_INET, AF_INET6,
AF_LOCAL? (Sorry, David))

> Index: network_io/unix/sockets.c
> ===================================================================
> RCS file: /home/cvs/apr/network_io/unix/sockets.c,v
> retrieving revision 1.90
> +        sock->local_addr->salen = sizeof(struct sockaddr_un);

this doesn't work perfectly with AF_UNIX...  the size as passed to
connect() should reflect the real path string once we know it...  but
there is nothing we can do at this point anyway because we don't know
the path string...

Your EGD code would need to set salen to SUN_PATH(sa.sunix) before
calling apr_connect().  And SUN_PATH() isn't provided everywhere, so
grab the one from Stevens' (MHRIP) UNP2eV2.

> +        sock->local_addr->addr_str_len = 108;

What about terminating '\0'?  Maybe it should be sizeof(sun_path) + 1?

Where's the rest?  Yeah, we don't need it yet for EGD, but why bother
until somebody is ready to implement a bunch of it at once so we can
think through the API issues?  (starting with (1) should we have
something that maps to an AF_UNIX socket on Unix and (2) should that
something be APR sockets and (3) what do we do on non-Unix platforms?)

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

Mime
View raw message