svn commit: r237199 - head/sys/kern
Pawel Jakub Dawidek
pjd at FreeBSD.org
Sun Jun 17 16:59:37 UTC 2012
Author: pjd
Date: Sun Jun 17 16:59:37 2012
New Revision: 237199
URL: http://svn.freebsd.org/changeset/base/237199
Log:
Extend the comment about checking for a race with close to explain why
it is done and why we don't return an error in such case.
Discussed with: kib
MFC after: 1 month
Modified:
head/sys/kern/kern_descrip.c
Modified: head/sys/kern/kern_descrip.c
==============================================================================
--- head/sys/kern/kern_descrip.c Sun Jun 17 16:32:32 2012 (r237198)
+++ head/sys/kern/kern_descrip.c Sun Jun 17 16:59:37 2012 (r237199)
@@ -672,7 +672,23 @@ kern_fcntl(struct thread *td, int fd, in
fdrop(fp, td);
break;
}
- /* Check for race with close */
+
+ /*
+ * Check for a race with close.
+ *
+ * The vnode is now advisory locked (or unlocked, but this case
+ * is not really important) as the caller requested.
+ * We had to drop the filedesc lock, so we need to recheck if
+ * the descriptor is still valid, because if it was closed
+ * in the meantime we need to remove advisory lock from the
+ * vnode - close on any descriptor leading to an advisory
+ * locked vnode, removes that lock.
+ * We will return 0 on purpose in that case, as the result of
+ * successful advisory lock might have been externally visible
+ * already. This is fine - effectively we pretend to the caller
+ * that the closing thread was a bit slower and that the
+ * advisory lock succeeded before the close.
+ */
FILEDESC_SLOCK(fdp);
if (fget_locked(fdp, fd) != fp) {
FILEDESC_SUNLOCK(fdp);
More information about the svn-src-all
mailing list