summaryrefslogtreecommitdiff
path: root/lib/libc_r/uthread/uthread_write.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc_r/uthread/uthread_write.c')
-rw-r--r--lib/libc_r/uthread/uthread_write.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/lib/libc_r/uthread/uthread_write.c b/lib/libc_r/uthread/uthread_write.c
index 7d91092f9ae..cac06ef3bb5 100644
--- a/lib/libc_r/uthread/uthread_write.c
+++ b/lib/libc_r/uthread/uthread_write.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: uthread_write.c,v 1.5 1999/11/25 07:01:47 d Exp $ */
/*
* Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
* All rights reserved.
@@ -20,7 +21,7 @@
* THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -29,8 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: uthread_write.c,v 1.10 1998/09/07 21:55:01 alex Exp $
- * $OpenBSD: uthread_write.c,v 1.4 1999/06/09 07:16:17 d Exp $
+ * $FreeBSD: uthread_write.c,v 1.12 1999/08/28 00:03:54 peter Exp $
*
*/
#include <sys/types.h>
@@ -51,18 +51,12 @@ write(int fd, const void *buf, size_t nbytes)
ssize_t num = 0;
ssize_t ret;
- /* This is a cancellation point: */
- _thread_enter_cancellation_point();
-
/* POSIX says to do just this: */
- if (nbytes == 0) {
- /* No longer in a cancellation point: */
- _thread_leave_cancellation_point();
- return (0);
- }
+ if (nbytes == 0)
+ ret = 0;
/* Lock the file descriptor for write: */
- if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) {
+ else if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) {
/* Get the read/write mode type: */
type = _thread_fd_table[fd]->flags & O_ACCMODE;
@@ -70,12 +64,10 @@ write(int fd, const void *buf, size_t nbytes)
if (type != O_WRONLY && type != O_RDWR) {
/* File is not open for write: */
errno = EBADF;
- _FD_UNLOCK(fd, FD_WRITE);
- /* No longer in a cancellation point: */
- _thread_leave_cancellation_point();
- return (-1);
+ ret = -1;
}
+ else {
/* Check if file operations are to block */
blocking = ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0);
@@ -136,7 +128,8 @@ write(int fd, const void *buf, size_t nbytes)
/* Return the number of bytes written: */
ret = num;
}
- _FD_UNLOCK(fd, FD_RDWR);
+ }
+ _FD_UNLOCK(fd, FD_WRITE);
}
/* No longer in a cancellation point: */