From: Derrick Brashear Date: Sun, 27 Nov 2011 15:42:59 +0000 (-0500) Subject: namei: force-close fd on read or write error X-Git-Tag: upstream/1.8.0_pre1^2~3015 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=730832073a1e87654f28bfff054e24d4170c01dc;p=packages%2Fo%2Fopenafs.git namei: force-close fd on read or write error if we errored, just reallyclose so we'll get a new fd Change-Id: I55de45a96dc7fab481a49c10c68f2ebc0d4ea27c Reviewed-on: http://gerrit.openafs.org/6126 Reviewed-by: Jeffrey Altman Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/vol/namei_ops.c b/src/vol/namei_ops.c index cd9245788..1f36d9b1b 100644 --- a/src/vol/namei_ops.c +++ b/src/vol/namei_ops.c @@ -77,7 +77,10 @@ namei_iread(IHandle_t * h, afs_foff_t offset, char *buf, afs_fsize_t size) return -1; nBytes = FDH_PREAD(fdP, buf, size, offset); - FDH_CLOSE(fdP); + if (nBytes < 0) + FDH_REALLYCLOSE(fdP); + else + FDH_CLOSE(fdP); return nBytes; } @@ -92,7 +95,10 @@ namei_iwrite(IHandle_t * h, afs_foff_t offset, char *buf, afs_fsize_t size) return -1; nBytes = FDH_PWRITE(fdP, buf, size, offset); - FDH_CLOSE(fdP); + if (nBytes < 0) + FDH_REALLYCLOSE(fdP); + else + FDH_CLOSE(fdP); return nBytes; }