#       dblock - lock and unlock of db for writing
#
#	$RCSfile: dblock.pl,v $
#	$Revision: 0.13 $
#	$Author: marten $
#	$Date: 1994/06/14 14:55:53 $
#
#	!!! LOCK BOTH TEXT FILE AND DBM FILE !!!
#
#	!!! NOTE: LOCKING DOES NOT WORK ON NFS FILESYSTEMS !!!

require "defines.pl";

sub dblock {

	local(*db) = @_;

	flock(db, $LOCK_EX);
	flock($db, $LOCK_EX);
	$lockcounter++;
}

sub dbunlock {

	local(*db) = @_;

	if ($lockcounter == 0) {
	    flock(db, $LOCK_UN);
	    flock($db, $LOCK_UN);
	} else {
	    $lockcounter--;
	}
}

1;
