diff options
| author | Julian Elischer <julian@FreeBSD.org> | 1997-02-05 23:26:09 +0000 | 
|---|---|---|
| committer | Julian Elischer <julian@FreeBSD.org> | 1997-02-05 23:26:09 +0000 | 
| commit | c840cec7c5df4547d37d9ca025553099b834c1aa (patch) | |
| tree | b2e6d3017e236268263978b585f2150cd10b1689 /lib/libpthread/thread/thr_readv.c | |
| parent | 3b576b3e5eac153732d10d222cc023a02adc3db7 (diff) | |
Notes
Diffstat (limited to 'lib/libpthread/thread/thr_readv.c')
| -rw-r--r-- | lib/libpthread/thread/thr_readv.c | 37 | 
1 files changed, 22 insertions, 15 deletions
| diff --git a/lib/libpthread/thread/thr_readv.c b/lib/libpthread/thread/thr_readv.c index acb72ac2b1b8..fed418b84229 100644 --- a/lib/libpthread/thread/thr_readv.c +++ b/lib/libpthread/thread/thr_readv.c @@ -42,22 +42,31 @@  ssize_t  readv(int fd, const struct iovec * iov, int iovcnt)  { -	int             nonblock; -	int             ret; -	int             status; -	if (fd < 0 || fd > _thread_dtablesize || _thread_fd_table[fd] == NULL) { -		_thread_seterrno(_thread_run, EBADF); -		ret = -1; -	} else if ((nonblock = _thread_fd_table[fd]->flags & O_NONBLOCK) == 0 && (ret = _thread_fd_lock(fd, FD_READ, NULL, __FILE__, __LINE__)) != 0) { -		/* Cannot lock file descriptor. */ -	} else { +	int	ret; +	int	status; + +	/* Lock the file descriptor for read: */ +	if ((ret = _thread_fd_lock(fd, FD_READ, NULL, +	    __FILE__, __LINE__)) == 0) { +		/* Perform a non-blocking readv syscall: */  		while ((ret = _thread_sys_readv(fd, iov, iovcnt)) < 0) { -			if (nonblock == 0 && (errno == EWOULDBLOCK || errno == EAGAIN)) { +			if (_thread_fd_table[fd]->flags & O_NONBLOCK == 0 && +			    (errno == EWOULDBLOCK || errno == EAGAIN)) {  				_thread_kern_sig_block(&status);  				_thread_run->data.fd.fd = fd;  				_thread_kern_set_timeout(NULL); -				_thread_kern_sched_state(PS_FDR_WAIT, __FILE__, __LINE__); -				if (errno == EINTR) { + +				/* Reset the interrupted operation flag: */ +				_thread_run->interrupted = 0; + +				_thread_kern_sched_state(PS_FDR_WAIT, +				    __FILE__, __LINE__); + +				/* +				 * Check if the operation was +				 * interrupted by a signal +				 */ +				if (_thread_run->interrupted) {  					ret = -1;  					break;  				} @@ -65,9 +74,7 @@ readv(int fd, const struct iovec * iov, int iovcnt)  				break;  			}  		} -		if (nonblock == 0) { -			_thread_fd_unlock(fd, FD_READ); -		} +		_thread_fd_unlock(fd, FD_READ);  	}  	return (ret);  } | 
