[Midnightbsd-cvs] src: uthread_close.c: libc_r close() fails if fstat() returns an error.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Tue Sep 25 11:25:42 EDT 2007
Log Message:
-----------
libc_r close() fails if fstat() returns an error. This causes problems with FreeBSD 4.x applications.
Since we don't control compat4x, this will never be fully resolved, but we can certainly fix our part.
Modified Files:
--------------
src/lib/libc_r/uthread:
uthread_close.c (r1.1.1.1 -> r1.2)
-------------- next part --------------
Index: uthread_close.c
===================================================================
RCS file: /home/cvs/src/lib/libc_r/uthread/uthread_close.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -Llib/libc_r/uthread/uthread_close.c -Llib/libc_r/uthread/uthread_close.c -u -r1.1.1.1 -r1.2
--- lib/libc_r/uthread/uthread_close.c
+++ lib/libc_r/uthread/uthread_close.c
@@ -63,8 +63,7 @@
* 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 = __sys_fstat(fd, &sb)) == 0)) {
+ else if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) {
/*
* Check if the file should be left as blocking.
*
@@ -85,7 +84,8 @@
* using, which would then cause any reads to block
* indefinitely.
*/
- if ((S_ISREG(sb.st_mode) || S_ISCHR(sb.st_mode))
+ if (__sys_fstat(fd, &sb) == 0 &&
+ (S_ISREG(sb.st_mode) || S_ISCHR(sb.st_mode))
&& (_thread_fd_getflags(fd) & O_NONBLOCK) == 0) {
/* Get the current flags: */
flags = __sys_fcntl(fd, F_GETFL, NULL);
More information about the Midnightbsd-cvs
mailing list