From: Erik Faye-Lund Date: Thu, 27 May 2010 13:46:28 GMT Subject: Re: [PATCH] compat: Add another rudimentary poll() emulation Message-ID: In-Reply-To: On Thu, May 27, 2010 at 3:29 PM, Marko Kreen wrote: > On 5/27/10, Erik Faye-Lund wrote: >> On Thu, May 27, 2010 at 1:00 PM, Erik Faye-Lund >>   wrote: >>  > On Thu, May 27, 2010 at 12:10 PM, Jonathan Nieder wrote: >>  >> Implement the subset of poll() semantics needed by git in terms of >>  >> select(), for use by the Interix port.  Inspired by commit 6ed807f >>  >> (Windows: A rudimentary poll() emulation, 2007-12-01). >>  >> >>  > >>  > A possible problem with this approach is that the maximum number of >>  > file descriptors poll can handle limited by RLIMIT_NOFILE, whereas the >>  > maximum number of file descriptors select can handle is limited by >>  > FD_SETSIZE. >>  > >>  > I don't think this is a big problem in reality, though - both values >>  > seem to be pretty high in most implementations. And IIRC git-daemon is >>  > the only one who needs more than 2, and it doesn't even check >>  > RLIMIT_NOFILE. >>  > >> >> >> To be clear: I think this strategy is the best option (at least for >>  non-Windows, where select() might be our only option). >> >>  But perhaps you should include a check along the lines of this: >> >>  if (nfds > FD_SETSIZE) >>         return errno = EINVAL, error("poll: nfds must be below %d", FD_SETSIZE); >> >>  Just so we can know when the code fails :) > > Well, per your own FD_SET example, the FD_SETSIZE on windows > means different thing than FD_SETSIZE on old-style bitmap-based > select() implementation. > > On Unix, it's max fd number + 1, on windows it's max count. > Are you sure this applies for all Unix, not just some given Unix-y system? > RLIMIT_NOFILE - I don't see why it is relevant here, as you > get error on open() when you cross the limit.  So how can you > pass more than that meny fds to select()/poll()? > Good point, this was my bad. -- Erik "kusma" Faye-Lund