From owner-freebsd-arch@FreeBSD.ORG Sat May 15 09:28:43 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B0B1316A4CE for ; Sat, 15 May 2004 09:28:43 -0700 (PDT) Received: from beastie.mckusick.com (dsl081-247-227.sfo1.dsl.speakeasy.net [64.81.247.227]) by mx1.FreeBSD.org (Postfix) with ESMTP id B93E843D1F for ; Sat, 15 May 2004 09:28:42 -0700 (PDT) (envelope-from mckusick@mckusick.com) Received: from beastie.mckusick.com (localhost [127.0.0.1]) by beastie.mckusick.com (8.12.8/8.12.9) with ESMTP id i4FGS7U9092172; Sat, 15 May 2004 09:28:10 -0700 (PDT) (envelope-from mckusick@beastie.mckusick.com) Message-Id: <200405151628.i4FGS7U9092172@beastie.mckusick.com> To: Yar Tikhiy In-Reply-To: Your message of "Sat, 15 May 2004 13:21:14 +0400." <20040515092114.GB67531@comp.chem.msu.su> Date: Sat, 15 May 2004 09:28:07 -0700 From: Kirk McKusick cc: arch@freebsd.org Subject: Re: Interoperation of flock(2), fcntl(2), and lockf(3) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2004 16:28:43 -0000 As the author of the original sentence, I concur that your proposed change is an improvement. I suggest that you make it. Kirk McKusick =-=-=-=-=-= Date: Sat, 15 May 2004 13:21:14 +0400 From: Yar Tikhiy To: arch@freebsd.org, hackers@freebsd.org Subject: Interoperation of flock(2), fcntl(2), and lockf(3) Hi folks, I've always been confused by the following sentence from the lockf(3) manpage: The lockf(), fcntl(2) and flock(2) locks may be safely used concurrently. Does that mean that each of those calls uses a locking mechanism of its own? Of course, in practice those calls use a mutual mechanism, thus allowing serial access to a file from applications using different calls. However, there's an oddity: While it's possible for a process to obtain the same lock several times w/o error (it's a no-op case of upgrading the lock,) intermixing flock(2) and fcntl(2), or flock(2) and lockf(3), within the same process results in EAGAIN upon the second locking attempt. That's while mixing fcntl(2) and lockf(3) is all right as long as the latter call is just a wrapper for the former one. Of course, intermixing different lock calls within one process is a poor idea at the first place, but I can imagine some mail application that tries to coax all the mailbox locking schemes at once. Considering all the above, I'd like to add the following paragraph to the flock(2), lockf(3), and fcntl(2) man pages (replacing the sentence quoted from lockf(3)): The flock(2), fcntl(2), and lockf(3) locks are compatible. Processes using different locking interfaces can cooperate over the same file safely. However, only one of such interfaces should be used within a process. If a file is locked by a process through flock(2), any record within the file will be seen as locked from the viewpoint of another process using fcntl(2) or lockf(3), and vice versa. Any objections or comments? -- Yar _______________________________________________ freebsd-arch@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-arch To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"