public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: cygwin-patches@cygwin.com
Subject: Re: [PATCH] Cygwin: getdtablesize: always return OPEN_MAX_MAX
Date: Thu, 28 Jan 2021 17:28:54 -0500	[thread overview]
Message-ID: <a4cd3c3f-d217-026a-3cce-b29187ecd1e9@cornell.edu> (raw)
In-Reply-To: <20210128161304.GC4393@calimero.vinschen.de>

On 1/28/2021 11:13 AM, Corinna Vinschen via Cygwin-patches wrote:
> On Jan 28 17:07, Corinna Vinschen via Cygwin-patches wrote:
>> On Jan 28 08:42, Ken Brown via Cygwin-patches wrote:
>>> On 1/28/2021 5:20 AM, Corinna Vinschen via Cygwin-patches wrote:
>>>> On Jan 27 21:51, Ken Brown via Cygwin-patches wrote:
>>>>> According to the Linux man page for getdtablesize(3), the latter is
>>>>> supposed to return "the maximum number of files a process can have
>>>>> open, one more than the largest possible value for a file descriptor."
>>>>> The constant OPEN_MAX_MAX is the only limit enforced by Cygwin, so we
>>>>> now return that.
>>>>>
>>>>> Previously getdtablesize returned the current size of cygheap->fdtab,
>>>>> Cygwin's internal file descriptor table.  But this is a dynamically
>>>>> growing table, and its current size does not reflect an actual limit
>>>>> on the number of open files.
>>>>>
>>>>> With this change, gnulib now reports that getdtablesize and
>>>>> fcntl(F_DUPFD) work on Cygwin.  Packages like GNU tar that use the
>>>>> corresponding gnulib modules will no longer use gnulib replacements on
>>>>> Cygwin.
>>>>> ---
>>>>>    winsup/cygwin/syscalls.cc | 2 +-
>>>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
>>>>> index 5da05b18a..1f16d54b9 100644
>>>>> --- a/winsup/cygwin/syscalls.cc
>>>>> +++ b/winsup/cygwin/syscalls.cc
>>>>> @@ -2887,7 +2887,7 @@ setdtablesize (int size)
>>>>>    extern "C" int
>>>>>    getdtablesize ()
>>>>>    {
>>>>> -  return cygheap->fdtab.size;
>>>>> +  return OPEN_MAX_MAX;
>>>>>    }
>>>>
>>>> getdtablesize is used internally, too.  After this change, the values
>>>> returned by sysconf and getrlimit should be revisited as well.
>>>
>>> They will now return OPEN_MAX_MAX, as I think they should.  The only
>>> question in my mind is whether to simplify the code by removing the calls to
>>> getdtablesize, something like this (untested):
>>
>> But then again, what happens with OPEN_MAX in limits.h?  Linux removed
>> it entirely.  Given we have such a limit and it's not flexible as on
>> Linux, should we go ahead, drop OPEN_MAX_MAX entirely and define
>> OPEN_MAX as 3200?
> 
> ...ideally by adding a file include/cygwin/limits.h included by
> include/limits.h, which defines __OPEN_MAX et al, as required.

I'm not completely sure I follow.  Do you mean include/cygwin/limits.h should 
contain

   #define __OPEN_MAX 3200

and include/limits.h should contain

   #define OPEN_MAX __OPEN_MAX ?

For the sake of my education, could you explain the reason for this?

Thanks.

Ken

  reply	other threads:[~2021-01-28 22:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-28  2:51 Ken Brown
2021-01-28 10:20 ` Corinna Vinschen
2021-01-28 13:42   ` Ken Brown
2021-01-28 16:07     ` Corinna Vinschen
2021-01-28 16:13       ` Corinna Vinschen
2021-01-28 22:28         ` Ken Brown [this message]
2021-01-29 19:23           ` Ken Brown
2021-02-01  9:42             ` Corinna Vinschen
2021-01-28 20:33       ` Ken Brown
2021-02-01  9:50         ` Corinna Vinschen
2021-02-01 10:46           ` Corinna Vinschen

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=a4cd3c3f-d217-026a-3cce-b29187ecd1e9@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=cygwin-patches@cygwin.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 read-only IMAP folder(s) and NNTP newsgroup(s).