Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Message-Id: <199910050417.VAA27657@herra.corp.netapp.com> To: cygwin AT sourceware DOT cygnus DOT com Subject: make_pipe() can sometimes fail to grow file descriptors Date: Mon, 04 Oct 1999 21:17:34 -0700 From: Lincoln Myers 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 AT sourceware DOT cygnus DOT com