From owner-freebsd-hackers Tue Aug 24 10: 5:33 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from peach.ocn.ne.jp (peach.ocn.ne.jp [210.145.254.87]) by hub.freebsd.org (Postfix) with ESMTP id B5CF71598D for ; Tue, 24 Aug 1999 09:59:34 -0700 (PDT) (envelope-from dcs@newsguy.com) Received: from newsguy.com by peach.ocn.ne.jp (8.9.1a/OCN) id XAA20428; Tue, 24 Aug 1999 23:48:56 +0900 (JST) Message-ID: <37C2B0A1.4E823BF9@newsguy.com> Date: Tue, 24 Aug 1999 23:48:01 +0900 From: "Daniel C. Sobral" X-Mailer: Mozilla 4.6 [en] (Win98; I) X-Accept-Language: en,pt-BR,ja MIME-Version: 1.0 To: Chuck Robey Cc: FreeBSD Hackers Subject: Re: Mandatory locking? References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Chuck Robey wrote: > > On Mon, 23 Aug 1999, Christopher Masto wrote: > > > Bleah.. I can't count the number of times I've seen idiotic code like: > > > > open file > > read data > > close file > > open file for write > > write data > > close file > > > > Mandatory locking of the type above doesn't force such a thing to work. > > What has that code you show above got to do with mandatory locking? > You completely missed the explicit locking calls that you have to make, > to get and release the locks. If you don't make the call, and you have > madatory locking, then your process will sleep until someone else > releases the lock; if you only have advisory locking, and you use the > miscreant code you show, then indeed things will go awry. You missed the point. Insert the appropriate locking&unlocking at each open/close operation. See? :-) -- Daniel C. Sobral (8-DCS) dcs@newsguy.com dcs@freebsd.org - Come on. - Where are we going? - To get what you came for. - What's that? - Me. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message