summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/uthread/uthread_fcntl.c
diff options
context:
space:
mode:
authormarc <marc@openbsd.org>2003-02-04 22:14:27 +0000
committermarc <marc@openbsd.org>2003-02-04 22:14:27 +0000
commit2c58a6ed58ae116f56ea454eedb1c1dc9677b218 (patch)
treeedb66ad54861bace0403d129698fe36a9cb02150 /lib/libpthread/uthread/uthread_fcntl.c
parentAdd test to compare threaded vs non-threaded fd handling. (diff)
downloadwireguard-openbsd-2c58a6ed58ae116f56ea454eedb1c1dc9677b218.tar.xz
wireguard-openbsd-2c58a6ed58ae116f56ea454eedb1c1dc9677b218.zip
Part 1 of thread fd handling fixes. In the new scheme fd_table_entries
for dup-ed fds are shared to ensure proper flag handling. A refcnt was added to control when entries should be freed. Specific changes: close: don't free entry unless refcnt is zero dup: rewrite to use new function _thread_fd_table_dup dup2: rewrite to use new function _thread_fd_table_dup fcntl: use _thread_fd_table_dup uthread_fd: initialize thread fd table, searching for dup-ed fds. Add function to share _thread_fd_table entries when an fd is dup-ed. uthread_init: make it readable. Call fd init functions. All current regression tests plus the mysql torture test pass. The new stdfiles regression test fails (I/O redirection problem). Part 2 is intended to fix that problem
Diffstat (limited to 'lib/libpthread/uthread/uthread_fcntl.c')
-rw-r--r--lib/libpthread/uthread/uthread_fcntl.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/lib/libpthread/uthread/uthread_fcntl.c b/lib/libpthread/uthread/uthread_fcntl.c
index 7070a564838..8955618efcd 100644
--- a/lib/libpthread/uthread/uthread_fcntl.c
+++ b/lib/libpthread/uthread/uthread_fcntl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_fcntl.c,v 1.6 1999/11/25 07:01:34 d Exp $ */
+/* $OpenBSD: uthread_fcntl.c,v 1.7 2003/02/04 22:14:27 marc Exp $ */
/*
* Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
* All rights reserved.
@@ -70,18 +70,12 @@ fcntl(int fd, int cmd,...)
if ((ret = _thread_sys_fcntl(fd, cmd, oldfd)) < 0) {
}
/* Initialise the file descriptor table entry: */
- else if (_thread_fd_table_init(ret) != 0) {
+ else if (_thread_fd_table_dup(fd, ret) != 0) {
/* Quietly close the file: */
_thread_sys_close(ret);
/* Reset the file descriptor: */
ret = -1;
- } else {
- /*
- * Save the file open flags so that they can
- * be checked later:
- */
- _thread_fd_table[ret]->flags = _thread_fd_table[fd]->flags;
}
break;
case F_SETFD: