From owner-freebsd-current Sat Nov 6 5:45:52 1999 Delivered-To: freebsd-current@freebsd.org Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11]) by hub.freebsd.org (Postfix) with SMTP id 4644B14DFE for ; Sat, 6 Nov 1999 05:45:49 -0800 (PST) (envelope-from dwmalone@maths.tcd.ie) Received: from walton.maths.tcd.ie by salmon.maths.tcd.ie with SMTP id ; 6 Nov 1999 13:45:48 +0000 (GMT) Date: Sat, 6 Nov 1999 13:45:48 +0000 From: David Malone To: Ollivier Robert Cc: FreeBSD Current Users' list Subject: Re: Serious locking problem in CURRENT Message-ID: <19991106134548.A2921@walton.maths.tcd.ie> References: <19991105225916.A14961@keltia.freenix.fr> <19991106005016.A865@keltia.freenix.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre3i In-Reply-To: <19991106005016.A865@keltia.freenix.fr> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sat, Nov 06, 1999 at 12:50:16AM +0100, Ollivier Robert wrote: A child process seems to be able to let go of a parent's lock on 4.0 by closing a file discriptor, the same doesn't seem to be true on 3.3. For example, if you try to run two copies of the included program as on 3.3, you get a resource unavailable message. 12:57:walton 6% ./lockf_test /tmp/blah 5 & [1] 2453 13:01:walton 7% ./lockf_test /tmp/blah 5 Unable to open file: Resource temporarily unavailable 13:01:walton 8% [1] Done ./lockf_test /tmp/blah 5 On 4.0 two run concurrently quite happily: 12:54:gonzo 65% ./lockf_test /tmp/blah 5 & [1] 943 13:02:gonzo 66% ./lockf_test /tmp/blah 5 [1] Done ./lockf_test /tmp/blah 5 13:02:gonzo 67% If you remove the "if(fork==0){close(fd);}" it two copies will not run concurrently on 4.0. I'm not sure which behavior is correct, but I suspect the 3.0 behavior is, 'cos /usr/bin/lockf is broken by this on 4.0. David. #include #include #include #include int main(int argc,char **argv) { int fd; if( argc != 3 ) { fprintf(stderr, "Usage: %s filename seconds\n", argv[0]); exit(1); } if( (fd = open(argv[1], O_RDONLY|O_CREAT|O_NONBLOCK|O_EXLOCK,0666)) == -1 ) { perror("Unable to open file"); exit(2); } if( fork() == 0 ) { close(fd); } sleep(atoi(argv[2])); exit(0); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message