Dear diary, on Thu, Jul 21, 2005 at 03:10:49PM CEST, I got a letter where "YOSHIFUJI Hideaki / ?$B5HF#1QL@" <[EMAIL PROTECTED]> told me that... > Hello.
Hello from an IPv6 fan, > Listen on IPv6 as well, if available. > > Signed-off-by: Hideaki YOSHIFUJI <[EMAIL PROTECTED]> > > diff --git a/daemon.c b/daemon.c > --- a/daemon.c > +++ b/daemon.c > @@ -219,37 +219,102 @@ static void child_handler(int signo) > > static int serve(int port) > { ..snip.. this whole getaddrinfo() magic looks horribly complicated. What's wrong on just adding a similar code (or factoring it out to a function) for IPv6 as there is for IPv4, just s/INET/INET6/? > for (;;) { > - struct sockaddr_in in; > - socklen_t addrlen = sizeof(in); > - int incoming = accept(sockfd, (void *)&in, &addrlen); > - > - if (incoming < 0) { > - switch (errno) { > - case EAGAIN: > - case EINTR: > - case ECONNABORTED: > - continue; > - default: > - die("accept returned %s", strerror(errno)); > + struct sockaddr_storage ss; > + socklen_t sslen = sizeof(ss); Perhaps move those to the most inner block. (All right, I'm nitpicking too much again, sorry.) > + > + int i; > + fds = fds_init; > + > + if (select(maxfd + 1, &fds, NULL, NULL, NULL) == -1) { > + /* warning? */ Certainly a warning and at least sleep(1) to avoid cpuburn-like behaviour in case of anything going wrong. > + continue; > + } > + > + for (i = 0; i < socknum; i++) { > + int sockfd = socklist[i]; > + > + if (FD_ISSET(sockfd, &fds)) { > + int incoming = accept(sockfd, (struct sockaddr > *)&ss, &sslen); > + if (incoming < 0) { > + switch (errno) { > + case EAGAIN: > + case EINTR: > + case ECONNABORTED: > + continue; > + default: > + die("accept returned %s", > strerror(errno)); > + } > + } > + handle(incoming, (struct sockaddr *)&ss, sslen); > } > } > - handle(incoming, &in, addrlen); > } > } -- Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ If you want the holes in your knowledge showing up try teaching someone. -- Alan Cox - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html