From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 16:59:37 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BE1F01065672; Sun, 17 Jun 2012 16:59:37 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AA5228FC12; Sun, 17 Jun 2012 16:59:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5HGxbWq018934; Sun, 17 Jun 2012 16:59:37 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5HGxbAZ018932; Sun, 17 Jun 2012 16:59:37 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201206171659.q5HGxbAZ018932@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sun, 17 Jun 2012 16:59:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237199 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 16:59:37 -0000 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);