git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Erik Faye-Lund <kusmabite@googlemail.com>
To: Marko Kreen <markokr@gmail.com>
Cc: Jonathan Nieder <jrnieder@gmail.com>,
	Jonathan Callen <abcd@gentoo.org>,
	git@vger.kernel.org, mduft@gentoo.org,
	Sverre Rabbelier <srabbelier@gmail.com>,
	Michael J Gruber <git@drmicha.warpmail.net>,
	Johannes Sixt <j6t@kdbg.org>, msysGit <msysgit@googlegroups.com>
Subject: Re: [PATCH] compat: Add another rudimentary poll() emulation
Date: Thu, 27 May 2010 16:15:01 +0200	[thread overview]
Message-ID: <AANLkTimo2P3JIJ2zhD3QtT2wgfr4WmXPkVVxUDpiOfJH@mail.gmail.com> (raw)
In-Reply-To: <AANLkTil-nMo5E2laacYm48-HGbhseEICWsUHwTlc3l47@mail.gmail.com>

On Thu, May 27, 2010 at 4:11 PM, Marko Kreen <markokr@gmail.com> wrote:
> On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:
>> On Thu, May 27, 2010 at 3:58 PM, Marko Kreen <markokr@gmail.com> wrote:
>>  > On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:
>>  >> On Thu, May 27, 2010 at 3:29 PM, Marko Kreen <markokr@gmail.com> wrote:
>>  >>  > On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:
>>  >>  >> On Thu, May 27, 2010 at 1:00 PM, Erik Faye-Lund
>>  >>  >>  <kusmabite@googlemail.com> wrote:
>>  >>  >>  > On Thu, May 27, 2010 at 12:10 PM, Jonathan Nieder <jrnieder@gmail.com> 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?
>>  >
>>  > Not sure.  Just pointing out that the above check is not
>>  > universal enough.
>>  >
>>
>>
>> Isn't it? How could one possibly pass more than max fd number + 1 file
>>  descriptors, since they start at 0? I guess one could specify a given
>>  fd more than once, but that'd be kind of redundant... and also very
>>  unlikely in our case ;)
>
> Pass one fd with value 70 it.  Check returns error, although
> everything would work.
>

No, not with the check I posted. I checked nfds, not the value of the
fds themselves. nfds is clearly the size of the fds array -- if it
wasn't, it'd be impossible for the poll-implementation to know how big
the array is!

-- 
Erik "kusma" Faye-Lund

  reply	other threads:[~2010-05-27 14:15 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-27  8:19 [PATCH 0/3] Interix support Jonathan Callen
2010-05-27  8:19 ` [PATCH 1/3] Support building on systems without poll(2) Jonathan Callen
2010-05-27  8:43   ` Sverre Rabbelier
2010-05-27 13:02     ` Jeff King
2010-05-27  8:51   ` Michael J Gruber
2010-05-27  9:13     ` Jonathan Callen
2010-05-27 10:10   ` [PATCH] compat: Add another rudimentary poll() emulation Jonathan Nieder
2010-05-27 11:00     ` Erik Faye-Lund
2010-05-27 11:39       ` Marko Kreen
2010-05-27 12:00         ` Erik Faye-Lund
2010-05-27 12:36           ` Marko Kreen
2010-05-27 12:57             ` Erik Faye-Lund
2010-05-27 13:43               ` [msysGit] " Albert Dvornik
2010-05-30  7:44             ` Paolo Bonzini
2010-05-27 13:06       ` Erik Faye-Lund
2010-05-27 13:29         ` Marko Kreen
2010-05-27 13:46           ` Erik Faye-Lund
2010-05-27 13:58             ` Marko Kreen
2010-05-27 14:06               ` Erik Faye-Lund
2010-05-27 14:11                 ` Marko Kreen
2010-05-27 14:15                   ` Erik Faye-Lund [this message]
2010-05-27 14:32                     ` Marko Kreen
2010-05-27 14:44                       ` Erik Faye-Lund
2010-05-27 15:17                         ` Peter Kjellerstedt
2010-05-27 14:14             ` [msysGit] " Albert Dvornik
2010-05-27 14:05         ` Albert Dvornik
2010-05-30  0:37         ` [PATCH v2] " Jonathan Nieder
2010-05-30 19:19           ` Johannes Sixt
2010-05-30 20:40             ` Jonathan Nieder
2010-05-30 22:39           ` Joshua Juran
2010-05-31  3:19             ` Mac OS 9 (Lamp) port Jonathan Nieder
2010-05-31  4:35               ` Joshua Juran
2010-05-31  5:49                 ` Jonathan Nieder
2010-05-31 12:12           ` [PATCH v2] compat: Add another rudimentary poll() emulation Albert Dvornik
2010-05-31 12:46             ` Jonathan Nieder
2010-05-31 13:10               ` Albert Dvornik
2010-05-27  8:19 ` [PATCH 2/3] Support building without inttypes.h Jonathan Callen
2010-05-27  8:19 ` [PATCH 3/3] Add Interix support Jonathan Callen
2010-05-28  2:11 ` [PATCH 0/3] " Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTimo2P3JIJ2zhD3QtT2wgfr4WmXPkVVxUDpiOfJH@mail.gmail.com \
    --to=kusmabite@googlemail.com \
    --cc=abcd@gentoo.org \
    --cc=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    --cc=jrnieder@gmail.com \
    --cc=kusmabite@gmail.com \
    --cc=markokr@gmail.com \
    --cc=mduft@gentoo.org \
    --cc=msysgit@googlegroups.com \
    --cc=srabbelier@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).