diff options
author | 2000-10-04 05:52:34 +0000 | |
---|---|---|
committer | 2000-10-04 05:52:34 +0000 | |
commit | 48f9bbb22d95ffc617b323baa35eb12a2bf1b6dc (patch) | |
tree | 50cc52236f93d6e5288954a34addc5196b964083 /lib/libpthread | |
parent | bit of a cleanup (diff) | |
download | wireguard-openbsd-48f9bbb22d95ffc617b323baa35eb12a2bf1b6dc.tar.xz wireguard-openbsd-48f9bbb22d95ffc617b323baa35eb12a2bf1b6dc.zip |
if fstat fails fails, as it will on some sockets, close anyway.
Diffstat (limited to 'lib/libpthread')
-rw-r--r-- | lib/libpthread/uthread/uthread_close.c | 14 |
1 files changed, 10 insertions, 4 deletions
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: */ |