diff options
author | Kurt Miller <kurt@cvs.openbsd.org> | 2006-09-22 19:04:34 +0000 |
---|---|---|
committer | Kurt Miller <kurt@cvs.openbsd.org> | 2006-09-22 19:04:34 +0000 |
commit | 7b0347847c0d6eea5eea4d695761d24f1b151d53 (patch) | |
tree | 1f3f8ccccc135dfe4bbb20426cc5557f14403d53 /lib/libpthread/uthread/uthread_write.c | |
parent | d18267fdcf69320a8929dd06de2610e29bbb2b75 (diff) |
Part 1 of file descriptor race and deadlock corrections.
File status flags should be shared for dup'ed file descriptors.
However fd_table_entry's should not be shared for dup'ed file
descriptors so they can be independently be closed without
interfering with dup'ed fd's.
- split out file status flags into its own structure
fs_flags to manage sharing of status flags between
dup'ed file descriptors.
- when duplicating a fd, initialize a new fd_table_entry
for the new fd, but share the status flags via status_flags.
- consolidate the code that sets the underlying system fd
to be non-blocking to a new function _thread_fs_flags_init()
- consolidate the code that sets the underlying system
fd back to blocking into a new function _thread_fs_flags_replace()
This change is needed as a prerequisite to the coming race
and deadlock corrections. okay marc@
Diffstat (limited to 'lib/libpthread/uthread/uthread_write.c')
-rw-r--r-- | lib/libpthread/uthread/uthread_write.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libpthread/uthread/uthread_write.c b/lib/libpthread/uthread/uthread_write.c index 393b9da65c7..71581d05387 100644 --- a/lib/libpthread/uthread/uthread_write.c +++ b/lib/libpthread/uthread/uthread_write.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_write.c,v 1.10 2003/12/22 00:33:42 brad Exp $ */ +/* $OpenBSD: uthread_write.c,v 1.11 2006/09/22 19:04:33 kurt Exp $ */ /* * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> * All rights reserved. @@ -62,7 +62,7 @@ write(int fd, const void *buf, size_t nbytes) /* Lock the file descriptor for write: */ else if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { /* Get the read/write mode type: */ - type = _thread_fd_table[fd]->flags & O_ACCMODE; + type = _thread_fd_table[fd]->status_flags->flags & O_ACCMODE; /* Check if the file is not open for write: */ if (type != O_WRONLY && type != O_RDWR) { @@ -73,7 +73,7 @@ write(int fd, const void *buf, size_t nbytes) else { /* Check if file operations are to block */ - blocking = ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0); + blocking = ((_thread_fd_table[fd]->status_flags->flags & O_NONBLOCK) == 0); /* * Loop while no error occurs and until the expected number |