summaryrefslogtreecommitdiffstats
path: root/lib/libc_r/uthread/uthread_accept.c
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>2002-08-29 23:06:07 +0000
committerdeischen <deischen@FreeBSD.org>2002-08-29 23:06:07 +0000
commit8347fcb52dac051382b95182fce08ee0fc642340 (patch)
tree24c4da9130c487d85f113d7fdfa44a22f470cb61 /lib/libc_r/uthread/uthread_accept.c
parent175524795910e8310c89ecf8adfddb91fc451e9e (diff)
downloadFreeBSD-src-8347fcb52dac051382b95182fce08ee0fc642340.zip
FreeBSD-src-8347fcb52dac051382b95182fce08ee0fc642340.tar.gz
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
Diffstat (limited to 'lib/libc_r/uthread/uthread_accept.c')
-rw-r--r--lib/libc_r/uthread/uthread_accept.c9
1 files changed, 5 insertions, 4 deletions
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);
}
OpenPOWER on IntegriCloud