From 8347fcb52dac051382b95182fce08ee0fc642340 Mon Sep 17 00:00:00 2001 From: deischen Date: Thu, 29 Aug 2002 23:06:07 +0000 Subject: Remove much of the dereferencing of the fd table entries to look at file flags and replace it with functions that will avoid null pointer checks. MFC to be done by archie ;-) PR: 42100 Reviewed by: archie, robert MFC after: 3 days --- lib/libc_r/uthread/uthread_accept.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/libc_r/uthread/uthread_accept.c') diff --git a/lib/libc_r/uthread/uthread_accept.c b/lib/libc_r/uthread/uthread_accept.c index e04b97b..8f90336 100644 --- a/lib/libc_r/uthread/uthread_accept.c +++ b/lib/libc_r/uthread/uthread_accept.c @@ -52,7 +52,8 @@ _accept(int fd, struct sockaddr * name, socklen_t *namelen) /* Enter a loop to wait for a connection request: */ while ((ret = __sys_accept(fd, name, namelen)) < 0) { /* Check if the socket is to block: */ - if ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0 && (errno == EWOULDBLOCK || errno == EAGAIN)) { + if ((_thread_fd_getflags(fd) & O_NONBLOCK) == 0 + && (errno == EWOULDBLOCK || errno == EAGAIN)) { /* Save the socket file descriptor: */ curthread->data.fd.fd = fd; curthread->data.fd.fname = __FILE__; @@ -99,9 +100,9 @@ _accept(int fd, struct sockaddr * name, socklen_t *namelen) * set the new socket flags to non-blocking, as that * will be the inherited state of the new socket. */ - if((ret > 0) && (_thread_fd_table[fd]->flags & O_NONBLOCK) == 0) - _thread_fd_table[ret]->flags &= ~O_NONBLOCK; - + if((ret > 0) && (_thread_fd_getflags(fd) & O_NONBLOCK) == 0) + _thread_fd_setflags(ret, + _thread_fd_getflags(ret) & ~O_NONBLOCK); /* Unlock the file descriptor: */ _FD_UNLOCK(fd, FD_RDWR); } -- cgit v1.1