From: Erik Faye-Lund Date: Wed, 02 Dec 2009 15:11:23 GMT Subject: Re: [PATCH/RFC 01/11] mingw: add network-wrappers for daemon Message-ID: <40aa078e0912020711v6dcebba1g511e6cacbbed16be@mail.gmail.com> In-Reply-To: <40aa078e0912020549s792eb3ffi93b2cfdc6b7219dd@mail.gmail.com> On Wed, Dec 2, 2009 at 2:49 PM, Erik Faye-Lund wrote: > On Wed, Dec 2, 2009 at 2:21 PM, Martin Storsjö wrote: >> On Wed, 2 Dec 2009, Erik Faye-Lund wrote: >>> @@ -854,6 +850,7 @@ static int service_loop(int socknum, int *socklist) >>>                                         } >>>                                 } >>>                                 handle(incoming, (struct sockaddr *)&ss, sslen); >>> >>> +                               break; >> >> What's this good for? >> > > When I clone git://localhost/some-repo, select() returns a fd-set with > both the IPv4 and IPv6 fds. After accept()'ing the first one, the > second call to accept() hangs. I solved this by accepting only the > first connection I got; the second one should be accepted in the next > round of the service loop (if still available). > Actually, it's no good - my code is broken. FD_SET() and FD_ISSET() needs wrapping to call _get_osfhandle() on the socket. Since this is not needed on Linux, the code ran just fine there. But on Windows, select() failed, but due to the following bug, it wasn't picked up: + if (select(0, &fds, NULL, NULL, &timeout) > 0) { changing the comparison around, revealed that select hadn't done anything so fds wasn't modified at all! Thus, I wrongly interpreted it as if both sockets had an awaiting connection, making IPv6 connections work (since they are on the first socket), but IPv4 not. I've corrected this locally, and I'll include the fixed patch in the next round. Thanks for pointing out the issue, causing me to second guess my "cure" :) -- Erik "kusma" Faye-Lund