diff options
author | Christopher Faylor <me@cgf.cx> | 2003-07-09 01:33:06 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2003-07-09 01:33:06 +0000 |
commit | 4d782b426a09120642906e12e21bf669b7bb77db (patch) | |
tree | 514a0f6f1034d3bf897b6f7d7c365779fa40c44b /winsup/cygwin/dtable.cc | |
parent | a42408549f7b286dda7f333b5b977caf67fc1cdd (diff) | |
download | cygnal-4d782b426a09120642906e12e21bf669b7bb77db.tar.gz cygnal-4d782b426a09120642906e12e21bf669b7bb77db.tar.bz2 cygnal-4d782b426a09120642906e12e21bf669b7bb77db.zip |
* cygheap.cc (creturn): Set appropriate errno when out of memory.
(ccalloc): Only issue system_printf when debugging.
* dtable.cc (dtable::extend): Only allocate 100 * the incremental growth size
max. Set errno appropriately.
(dtable::build_fhandler): Check for error from set_name.
* fhandler.cc (fhandler_base::set_name): Set errno and return error on OOM.
* fhandler.h (fhandler_base::set_name): Change to bool.
* fhandler_process.cc (format_process_stat): Fix formatting.
* resource.cc (getrlimit): Return greater of OPEN_MAX or fd table size.
* sysconf.cc (sysconf): Ditto.
Diffstat (limited to 'winsup/cygwin/dtable.cc')
-rw-r--r-- | winsup/cygwin/dtable.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 973b3c429..fd7d579bb 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -65,18 +65,25 @@ dtable::extend (int howmuch) if (howmuch <= 0) return 0; + if (new_size > (100 * NOFILE_INCR)) + { + set_errno (EMFILE); + return 0; + } + /* Try to allocate more space for fd table. We can't call realloc () here to preserve old table if memory allocation fails */ if (!(newfds = (fhandler_base **) ccalloc (HEAP_ARGV, new_size, sizeof newfds[0]))) { debug_printf ("calloc failed"); + set_errno (ENOMEM); return 0; } if (fds) { - memcpy (newfds, fds, size * sizeof (fds[0])); cfree (fds); + memcpy (newfds, fds, size * sizeof (fds[0])); } size = new_size; @@ -404,7 +411,8 @@ dtable::build_fhandler (int fd, DWORD dev, char *unix_name, for (p = (char *) win32_name; (p = strchr (p, '/')); p++) *p = '\\'; } - fh->set_name (unix_name, win32_name, fh->get_unit ()); + if (!fh->set_name (unix_name, win32_name, fh->get_unit ())) + return NULL; } debug_printf ("fd %d, fh %p", fd, fh); return fd >= 0 ? (fds[fd] = fh) : fh; |