diff options
author | David Leonard <d@cvs.openbsd.org> | 2000-10-04 05:52:35 +0000 |
---|---|---|
committer | David Leonard <d@cvs.openbsd.org> | 2000-10-04 05:52:35 +0000 |
commit | 367c0082943cc6fa224d021a045222f13f86cfe4 (patch) | |
tree | 50a3a0c63256ebf1d2d6dd4a324b1575e82c0621 | |
parent | 97966e1a9da9b5b748fbf2fffdb473b9b79d4f00 (diff) |
if fstat fails fails, as it will on some sockets, close anyway.
-rw-r--r-- | lib/libc_r/uthread/uthread_close.c | 14 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_close.c | 14 |
2 files changed, 20 insertions, 8 deletions
diff --git a/lib/libc_r/uthread/uthread_close.c b/lib/libc_r/uthread/uthread_close.c index dcc1164b803..87b86611469 100644 --- a/lib/libc_r/uthread/uthread_close.c +++ b/lib/libc_r/uthread/uthread_close.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_close.c,v 1.7 2000/01/06 07:14:28 d Exp $ */ +/* $OpenBSD: uthread_close.c,v 1.8 2000/10/04 05:52:34 d Exp $ */ /* * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> * All rights reserved. @@ -63,8 +63,7 @@ close(int fd) * Lock the file descriptor while the file is closed and get * the file descriptor status: */ - else if (((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) && - ((ret = _thread_sys_fstat(fd, &sb)) == 0)) { + else if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { /* * Check if the file should be left as blocking. * @@ -84,8 +83,15 @@ close(int fd) * descriptor of the end of the pipe that they are not * using, which would then cause any reads to block * indefinitely. + * + * Files that we cannot fstat are probably not regular + * so we don't bother with them. */ - if ((S_ISREG(sb.st_mode) || S_ISCHR(sb.st_mode)) && (_thread_fd_table[fd]->flags & O_NONBLOCK) == 0) { + + if ((_thread_sys_fstat(fd, &sb) == 0) && + ((S_ISREG(sb.st_mode) || S_ISCHR(sb.st_mode)) && + (_thread_fd_table[fd]->flags & O_NONBLOCK) == 0)) + { /* Get the current flags: */ flags = _thread_sys_fcntl(fd, F_GETFL, NULL); /* Clear the nonblocking file descriptor flag: */ diff --git a/lib/libpthread/uthread/uthread_close.c b/lib/libpthread/uthread/uthread_close.c index dcc1164b803..87b86611469 100644 --- a/lib/libpthread/uthread/uthread_close.c +++ b/lib/libpthread/uthread/uthread_close.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_close.c,v 1.7 2000/01/06 07:14:28 d Exp $ */ +/* $OpenBSD: uthread_close.c,v 1.8 2000/10/04 05:52:34 d Exp $ */ /* * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> * All rights reserved. @@ -63,8 +63,7 @@ close(int fd) * Lock the file descriptor while the file is closed and get * the file descriptor status: */ - else if (((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) && - ((ret = _thread_sys_fstat(fd, &sb)) == 0)) { + else if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { /* * Check if the file should be left as blocking. * @@ -84,8 +83,15 @@ close(int fd) * descriptor of the end of the pipe that they are not * using, which would then cause any reads to block * indefinitely. + * + * Files that we cannot fstat are probably not regular + * so we don't bother with them. */ - if ((S_ISREG(sb.st_mode) || S_ISCHR(sb.st_mode)) && (_thread_fd_table[fd]->flags & O_NONBLOCK) == 0) { + + if ((_thread_sys_fstat(fd, &sb) == 0) && + ((S_ISREG(sb.st_mode) || S_ISCHR(sb.st_mode)) && + (_thread_fd_table[fd]->flags & O_NONBLOCK) == 0)) + { /* Get the current flags: */ flags = _thread_sys_fcntl(fd, F_GETFL, NULL); /* Clear the nonblocking file descriptor flag: */ |