This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
make_pipe() can sometimes fail to grow file descriptors
- To: cygwin at sourceware dot cygnus dot com
- Subject: make_pipe() can sometimes fail to grow file descriptors
- From: Lincoln Myers <lincoln at netapp dot com>
- Date: Mon, 04 Oct 1999 21:17:34 -0700
In looking around to find why a perl program of mine is being limited
to about 60 file descriptors, I think I've found what might be the
problem (by inspection only so far, so I still have to convince you
with words rather than deeds :)) an off-by-one error in how
make_pipe() calls hinfo::find_unused_inode(). I'm using B20.1, but I
see the same code in the 1999/10/03 winsup snapshot.
make_pipe contains:
if ((fdr = dtable.find_unused_handle ()) < 0)
set_errno (ENMFILE);
else if ((fdw = dtable.find_unused_handle (fdr + 1)) < 0)
set_errno ( ENMFILE);
else
...
In make_pipe,
fdr = dtable.find_unused_handle()
might return fdr to be be the last currently allocated handle (which
would be dtable.size-1). But then
dtable.find_unused_handle(fdr+1)
would be equivalent to
dtable.find_unused_handle(dtable.size)
which as can be seen in hinfo::find_unused_handle():
if ((size_t)start >= size)
return -1;
would return -1, and thus make_pipe() returns ENMFILE when Win32 and
memory would still allow more files and file descriptors. Unless this
would upset one of its other callers, I think a good fix would be to
change the test in hinfo::find_unused_handle() to this:
if ((size_t)start > size)
return -1;
-----
Lincoln
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com