package Lock;
-use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS $Timeout $violentTimeout $masterTimeout $iAmMaster);
+use vars qw(@EXPORT_OK %EXPORT_TAGS $Timeout $violentTimeout $masterTimeout $iAmMaster);
# ====================================================
# Funktionsexport
# ====================================================
-require Exporter;
-@ISA = qw(Exporter);
+use base qw(Exporter);
@EXPORT_OK = qw(lock_file unlock_file write_lock_file write_unlock_file
violent_unlock_file set_master_lock release_file);
# Neuen Referenzwert schreiben
$old+=$z;
$old=0 if ($old < 0);
- open REF,">$reffile" or return 0;
- print REF $old;
- close REF or return 0;
+ if ($old == 0)
+ {
+ unlink $reffile or return 0;
+ }
+ else
+ {
+ open REF,">$reffile" or return 0;
+ print REF $old or return 0;
+ close REF or return 0;
+ }
# wieder entsperren
return 0 unless(&simple_unlock($reffile));
# Neuen Referenzwert schreiben
$old += $z;
$old = 0 if ($old < 0);
- open REF,">$reffile" or return 0;
- print REF $old;
- close REF or return 0;
+ if ($old == 0)
+ {
+ unlink $reffile or return 0;
+ }
+ else
+ {
+ open REF,">$reffile" or return 0;
+ print REF $old or return 0;
+ close REF or return 0;
+ }
# wieder entsperren
return 0 unless(&simple_unlock($reffile));