summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2013-12-01 02:52:54 +0000
committerChristopher Faylor <me@cgf.cx>2013-12-01 02:52:54 +0000
commit499494d2cca1f8cf69f54d03437692582bf8415c (patch)
treef94e1f345b9e7cecb6dc27d0ca68956bcb87e380
parent483c843a6a67780f4072726c40c51f11b08cb55f (diff)
downloadcygnal-499494d2cca1f8cf69f54d03437692582bf8415c.tar.gz
cygnal-499494d2cca1f8cf69f54d03437692582bf8415c.tar.bz2
cygnal-499494d2cca1f8cf69f54d03437692582bf8415c.zip
* dtable.h (dtable::first_fd_for_open): Change declaration to size_t.
(dtable::extend): Change parameter to size_t. (dtable::find_unused_handle): Ditto. * dtable.cc: Remove now-unused header. (dtable::extend): Remove pointless test. Change parameter to size_t. (dtable::find_unused_handle): Rework to avoid MAX calculation in extend() call. Change parameter to size_t.
-rw-r--r--winsup/cygwin/ChangeLog10
-rw-r--r--winsup/cygwin/dtable.cc12
-rw-r--r--winsup/cygwin/dtable.h6
3 files changed, 18 insertions, 10 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index e4fda53ac..29294107e 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,15 @@
2013-11-30 Christopher Faylor <me.cygwin2013@cgf.cx>
+ * dtable.h (dtable::first_fd_for_open): Change declaration to size_t.
+ (dtable::extend): Change parameter to size_t.
+ (dtable::find_unused_handle): Ditto.
+ * dtable.cc: Remove now-unused header.
+ (dtable::extend): Remove pointless test. Change parameter to size_t.
+ (dtable::find_unused_handle): Rework to avoid MAX calculation in
+ extend() call. Change parameter to size_t.
+
+2013-11-30 Christopher Faylor <me.cygwin2013@cgf.cx>
+
* dtable.cc (build_fh_pc): When creating an archetype, use native name
rather than unix name if name doesn't exist.
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index 7cf52c4bc..bbec732a5 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -16,7 +16,6 @@ details. */
#include <stdio.h>
#include <unistd.h>
#include <wchar.h>
-#include <sys/param.h>
#define USE_SYS_TYPES_FD_SET
#include <winsock.h>
@@ -73,14 +72,11 @@ set_std_handle (int fd)
}
int
-dtable::extend (int howmuch)
+dtable::extend (size_t howmuch)
{
int new_size = size + howmuch;
fhandler_base **newfds;
- if (howmuch <= 0)
- return 0;
-
if (new_size > OPEN_MAX_MAX)
{
set_errno (EMFILE);
@@ -225,8 +221,10 @@ dtable::delete_archetype (fhandler_base *fh)
}
int
-dtable::find_unused_handle (int start)
+dtable::find_unused_handle (size_t start)
{
+ size_t extendby = (start > size) ? start - size : NOFILE_INCR;
+ /* This do loop should only ever execute twice. */
do
{
for (size_t i = start; i < size; i++)
@@ -234,7 +232,7 @@ dtable::find_unused_handle (int start)
if (fds[i] == NULL)
return i;
}
- while (extend (MAX (NOFILE_INCR, start - size)));
+ while (extend (extendby));
return -1;
}
diff --git a/winsup/cygwin/dtable.h b/winsup/cygwin/dtable.h
index 5810e04fe..f0e484c01 100644
--- a/winsup/cygwin/dtable.h
+++ b/winsup/cygwin/dtable.h
@@ -32,7 +32,7 @@ class dtable
unsigned narchetypes;
unsigned farchetype;
static const int initial_archetype_size = 8;
- int first_fd_for_open;
+ size_t first_fd_for_open;
int cnt_need_fixup_before;
void lock () {lock_process::locker.acquire ();}
void unlock () {lock_process::locker.release ();}
@@ -54,7 +54,7 @@ public:
void vfork_parent_restore ();
void vfork_child_fixup ();
fhandler_base *dup_worker (fhandler_base *oldfh, int flags);
- int extend (int howmuch);
+ int extend (size_t howmuch);
void fixup_after_fork (HANDLE);
void fixup_close (size_t, fhandler_base *);
@@ -65,7 +65,7 @@ public:
unlock ();
return res;
}
- int find_unused_handle (int start);
+ int find_unused_handle (size_t start);
int find_unused_handle () { return find_unused_handle (first_fd_for_open);}
void __reg2 release (int fd);
void init_std_file_from_handle (int fd, HANDLE handle);