thr_readv.c (95948) | thr_readv.c (102590) |
---|---|
1/* 2 * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * | 1/* 2 * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * |
32 * $FreeBSD: head/lib/libkse/thread/thr_readv.c 95948 2002-05-02 19:58:43Z archie $ | 32 * $FreeBSD: head/lib/libkse/thread/thr_readv.c 102590 2002-08-29 23:06:07Z deischen $ |
33 * 34 */ 35#include <sys/types.h> 36#include <sys/fcntl.h> 37#include <sys/uio.h> 38#include <errno.h> 39#include <unistd.h> 40#include <pthread.h> --- 6 unchanged lines hidden (view full) --- 47{ 48 struct pthread *curthread = _get_curthread(); 49 int ret; 50 int type; 51 52 /* Lock the file descriptor for read: */ 53 if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) { 54 /* Get the read/write mode type: */ | 33 * 34 */ 35#include <sys/types.h> 36#include <sys/fcntl.h> 37#include <sys/uio.h> 38#include <errno.h> 39#include <unistd.h> 40#include <pthread.h> --- 6 unchanged lines hidden (view full) --- 47{ 48 struct pthread *curthread = _get_curthread(); 49 int ret; 50 int type; 51 52 /* Lock the file descriptor for read: */ 53 if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) { 54 /* Get the read/write mode type: */ |
55 type = _thread_fd_table[fd]->flags & O_ACCMODE; | 55 type = _thread_fd_getflags(fd) & O_ACCMODE; |
56 57 /* Check if the file is not open for read: */ 58 if (type != O_RDONLY && type != O_RDWR) { 59 /* File is not open for read: */ 60 errno = EBADF; 61 _FD_UNLOCK(fd, FD_READ); 62 return (-1); 63 } 64 65 /* Perform a non-blocking readv syscall: */ 66 while ((ret = __sys_readv(fd, iov, iovcnt)) < 0) { | 56 57 /* Check if the file is not open for read: */ 58 if (type != O_RDONLY && type != O_RDWR) { 59 /* File is not open for read: */ 60 errno = EBADF; 61 _FD_UNLOCK(fd, FD_READ); 62 return (-1); 63 } 64 65 /* Perform a non-blocking readv syscall: */ 66 while ((ret = __sys_readv(fd, iov, iovcnt)) < 0) { |
67 if ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0 && | 67 if ((_thread_fd_getflags(fd) & O_NONBLOCK) == 0 && |
68 (errno == EWOULDBLOCK || errno == EAGAIN)) { 69 curthread->data.fd.fd = fd; 70 _thread_kern_set_timeout(NULL); 71 72 /* Reset the interrupted operation flag: */ 73 curthread->interrupted = 0; 74 75 _thread_kern_sched_state(PS_FDR_WAIT, --- 31 unchanged lines hidden --- | 68 (errno == EWOULDBLOCK || errno == EAGAIN)) { 69 curthread->data.fd.fd = fd; 70 _thread_kern_set_timeout(NULL); 71 72 /* Reset the interrupted operation flag: */ 73 curthread->interrupted = 0; 74 75 _thread_kern_sched_state(PS_FDR_WAIT, --- 31 unchanged lines hidden --- |