The hang turned out to by caused by this line: hp = gethostbyaddr((char *)&cli_addr, clien, AF_INET);
My vague understanding of this issue with nss-mdns and reverse lookups is based on a message from Lennart Poettering to #348578: > If the order of "mdns" and "dns" is swapped in nsswitch.conf, reverse > host name lookups will always be tried first with multicast DNS -- > which will fail in most cases, and thus adds a 3s delay to most calls > to gethostbyaddr(), which is unacceptable. I've lost track of whether we're following Lennart's recommendation for ordering, but reverse lookups still behave as he describes. At first I considered just removing this reverse lookup, as the hostname is barely used. But then I remembered that gethostbyaddr is deprecated anyway. Thus the attached patch, which converts it to use the shinier getnameinfo. Happily, getnameinfo does not hang, so this fixes the problem for me. ---- FWIW, I'm using simpleproxy to implement a MPD proxy. My proxy can be told to switch between MPD servers on the network, which it accomplishes by simply killing and restarting simpleproxy. MPD clients such as Sonata can thus be pointed at the proxy and transparently directed to whatever MPD server you want to use, which is much nicer than changing all their settings by hand each time. -- see shy jo
Only in simpleproxy-3.4: Makefile Only in simpleproxy-3.4: build-stamp Only in simpleproxy-3.4: cfg.o Only in simpleproxy-3.4: config.cache Only in simpleproxy-3.4: config.log Only in simpleproxy-3.4: config.status Common subdirectories: old/simpleproxy-3.4/debian and simpleproxy-3.4/debian Only in simpleproxy-3.4: patch-stamp Only in simpleproxy-3.4: simpleproxy diff -u old/simpleproxy-3.4/simpleproxy.c simpleproxy-3.4/simpleproxy.c --- old/simpleproxy-3.4/simpleproxy.c 2005-08-26 00:45:46.000000000 -0400 +++ simpleproxy-3.4/simpleproxy.c 2008-12-08 18:43:47.000000000 -0500 @@ -78,6 +78,9 @@ #include <arpa/inet.h> #include <ctype.h> +#include <sys/socket.h> +#include <netdb.h> + #include "cfg.h" #ifndef nil @@ -166,6 +169,9 @@ int rsp = 1; char *http_auth = nil; char *HTTPAuthHash = nil; + struct sockaddr *sa; + int len; + char hbuf[NI_MAXHOST]; /* Check for the arguments, and overwrite values from cfg file */ while((c = getopt(ac, av, "iVv7dhL:R:H:f:p:P:D:S:s:a:t:")) != -1) @@ -394,8 +400,11 @@ break; case 0: /* Child */ - hp = gethostbyaddr((char *)&cli_addr, clien, AF_INET); - client_name = strdup(hp?(hp->h_name): inet_ntoa(cli_addr.sin_addr)); + if (getnameinfo((const struct sockaddr *) &cli_addr, len, + hbuf, sizeof(hbuf), NULL, 0, 0) == 0) + client_name = strdup(hbuf); + else + client_name = inet_ntoa(cli_addr.sin_addr); /* * I don't know is that a bug, but on Irix 6.2 parent diff -u old/simpleproxy-3.4/simpleproxy.man simpleproxy-3.4/simpleproxy.man --- old/simpleproxy-3.4/simpleproxy.man 2005-08-22 21:31:20.000000000 -0400 +++ simpleproxy-3.4/simpleproxy.man 2008-12-08 18:23:02.000000000 -0500 @@ -68,7 +68,7 @@ .SH BUGS\ \ \ \ Only \fItcp\fP ports are supported. -.TP8 +.TP 8 .PP .SH SEE ALSO Only in simpleproxy-3.4: simpleproxy.o
signature.asc
Description: Digital signature