The default listen for 0.0.0.0 does not actually listen on 0.0.0.0 on FreeBSD (8.4 tested); it listens on ::1.

This happens because the IPV6_V6ONLY flag has not been turned off. It may default to off in Linux but on in FreeBSD, resulting in this not being discovered until now.

I don't know if the right thing to do is always turn this off or not though, so here's a simple patch that only turns it off if a null host was passed in. This really isn't the "right" thing to do either though; I don't think getaddrinfo() and the resultant loop should be called at all in the case of a null host, but that's a bit too involved for me to get into right now.

--- net.c.orig  2012-10-31 23:10:44.000000000 +0000
+++ net.c       2014-02-12 19:14:59.000000000 +0000
@@ -115,6 +115,18 @@
               printf("bind %d %s:%s\n", fd, h, p);
           }
       }
+
+      if (NULL == host)
+      {
+        flags = 0;
+ r = setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &flags, sizeof(flags));
+        if (r == -1) {
+          twarn("setting IPV6_V6ONLY off on fd %d", fd);
+          close(fd);
+          continue;
+        }
+      }
+
       r = bind(fd, ai->ai_addr, ai->ai_addrlen);
       if (r == -1) {
         twarn("bind()");

--
You received this message because you are subscribed to the Google Groups 
"beanstalk-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/beanstalk-talk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to