public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* make_pipe() can sometimes fail to grow file descriptors
@ 1999-10-04 21:17 Lincoln Myers
  1999-10-31 19:54 ` Lincoln Myers
  0 siblings, 1 reply; 2+ messages in thread
From: Lincoln Myers @ 1999-10-04 21:17 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* make_pipe() can sometimes fail to grow file descriptors
  1999-10-04 21:17 make_pipe() can sometimes fail to grow file descriptors Lincoln Myers
@ 1999-10-31 19:54 ` Lincoln Myers
  0 siblings, 0 replies; 2+ messages in thread
From: Lincoln Myers @ 1999-10-31 19:54 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-10-31 19:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-10-04 21:17 make_pipe() can sometimes fail to grow file descriptors Lincoln Myers
1999-10-31 19:54 ` Lincoln Myers

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).