From: Andrew Deason Date: Thu, 18 Feb 2010 17:42:27 +0000 (-0600) Subject: VLockFile: Do not close fd on lock failure X-Git-Tag: openafs-devel-1_5_73~138 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=cbf5f6341c389b0ae85f797ee7c73ba430a8b8f1;p=packages%2Fo%2Fopenafs.git VLockFile: Do not close fd on lock failure When we fail to acquire a lock in _VLockFd, do not close the fd if we fail to acquire the lock for any reason, since VLockFile does that for us already. There also may be other locks on that file, and we clearly do not want to release them when just one lock fails. VLockFile takes care of the necessary refcounting and fd closing, so don't do it in _VLockFd too. Change-Id: I65f27837dad033e0e84faf4aa0fb71ff26feda83 Reviewed-on: http://gerrit.openafs.org/1344 Tested-by: Andrew Deason Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/vol/vutil.c b/src/vol/vutil.c index 09360e80f..8b28f9c95 100644 --- a/src/vol/vutil.c +++ b/src/vol/vutil.c @@ -892,10 +892,8 @@ _VLockFd(FD_t handle, afs_uint32 offset, int locktype, int nonblock) if (!LockFileEx(handle, flags, 0, 1, 0, &lap)) { if (GetLastError() == ERROR_LOCK_VIOLATION) { - CloseHandle(handle); return EBUSY; } - CloseHandle(handle); return EIO; } @@ -977,12 +975,10 @@ _VLockFd(int fd, afs_uint32 offset, int locktype, int nonblock) if (fcntl(fd, cmd, &sf)) { if (nonblock && (errno == EACCES || errno == EAGAIN)) { /* We asked for a nonblocking lock, and it was already locked */ - close(fd); return EBUSY; } Log("_VLockFd: fcntl failed with error %d when trying to lock " "fd %d (locktype=%d)\n", errno, fd, locktype); - close(fd); return EIO; }