From 146491beed4abc9ad87a46ffd2aa8df94e441388 Mon Sep 17 00:00:00 2001 From: janwas Date: Thu, 5 Aug 2004 12:45:27 +0000 Subject: [PATCH] add too-many-file open warning when opening, too (but the underlying problem is fixed) This was SVN commit r907. --- source/lib/sysdep/win/wposix.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source/lib/sysdep/win/wposix.cpp b/source/lib/sysdep/win/wposix.cpp index 4d36bf51ce..135d09e28c 100755 --- a/source/lib/sysdep/win/wposix.cpp +++ b/source/lib/sysdep/win/wposix.cpp @@ -66,12 +66,13 @@ int open(const char* fn, int oflag, ...) va_end(args); } - WIN_SAVE_LAST_ERROR; - + WIN_SAVE_LAST_ERROR; // CreateFile int fd = _open(fn, oflag, mode); -debug_out("open %s = %d\n", fn, fd); WIN_RESTORE_LAST_ERROR; +#ifdef PARANOIA +debug_out("open %s = %d\n", fn, fd); +#endif // open it for async I/O as well (_open defaults to deny_none sharing) if(fd > 2) @@ -82,13 +83,21 @@ debug_out("open %s = %d\n", fn, fd); aio_reopen(fd, fn, oflag); } + // CRT doesn't like more than 255 files open. + // warn now, so that we notice why so many are open + if(fd > 256) + debug_warn("wposix: too many files open (CRT limitation)"); + return fd; } int close(int fd) { +#ifdef PARANOIA debug_out("close %d\n", fd); +#endif + assert(3 <= fd && fd < 256); aio_close(fd); return _close(fd);