- unless (-l &masterlockfile($filename)) {
- # try do decrement the reference counter
- #
- &set_ref($filename,-1,$timeout) and return 1;}
+ if ($LOCKED{$filename}) {
+ if ($LOCKED{$filename} == 3) {
+ return unless write_unlock_file($filename, $timeout);
+ $LOCKED{$filename} = 1;
+ }
+ if ($LOCKED{$filename} == 1) {
+ unless (-l masterlockfile($filename)) {
+ # try to decrement the reference counter
+ #
+ set_ref($filename,-1,$timeout) and do {
+ delete $LOCKED{$filename};
+ return 1;
+ }
+ }