diff options
author | Marco S Hyman <marc@cvs.openbsd.org> | 2003-02-04 22:14:28 +0000 |
---|---|---|
committer | Marco S Hyman <marc@cvs.openbsd.org> | 2003-02-04 22:14:28 +0000 |
commit | 5f11a81a04b25b7f64a86ad418f79529df7cae52 (patch) | |
tree | 5f656a0decb261f61791bf87d1919c2f25de511a /lib/libpthread/uthread/uthread_fcntl.c | |
parent | 0691abffebb064ad7318896c4ee8b0a26b049654 (diff) |
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.c | 10 |
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: |