Re: [PATCH/RFC 01/11] mingw: add network-wrappers for daemon
- From
Johannes Sixt <j6t@kdbg.org>
- Date
- Dec 2, 2009, 19:34 UTC
- Message-ID
- <200912022034.09266.j6t@kdbg.org>
- In-Reply-To
- <40aa078e0912020501v9378c37l106e1e23b5e7b43d@mail.gmail.com>
On Mittwoch, 2. Dezember 2009, Erik Faye-Lund wrote:
Show 14 quoted lines
> I'm not very familiar with poll(), but if I understand the man-pages > correctly it's waiting for events on file descriptors, and is in our > case used to check for incoming connections, right? If so, I see three > possible ways forward: (1) extending our poll()-emulation to handle > multiple sockets, (2) change daemon.c to check one socket at the time, > and (3) using select() instead of poll(). > > (1) seems like the "correct" but tricky thing to do, (2) like the > "easy" but nasty thing to do. However, (3) strikes me as the least > dangerous thing to do ;) > > For (1), there's also a WSAPoll() function in Windows, but I'm not > sure how to figure out if an fd is a socket or a pipe. There's also > WaitForMultipleObjects.
GetFileType() returns FILE_TYPE_PIPE for both pipes and sockets. But once you know this, you can use getsockopt(): If it succeeds, it is a socket, and in this case, assume that poll() was called from git-daemon, i.e. all polled-for fds are sockets and you can select().
-- Hannes