]> git.p6c8.net - selfforum.git/blobdiff - selfforum-cgi/shared/Lock.pm
shared/Lock.pm: fixed a small bug (now returns 0 if occupied)
[selfforum.git] / selfforum-cgi / shared / Lock.pm
index f878aea9856b49cb0ad8349e0e05e133cb918095..f3291c6daaeb1c57487b8fb54ddb7fda308f3d36 100644 (file)
@@ -12,7 +12,6 @@ package Lock;
 
 use strict;
 use Carp;
 
 use strict;
 use Carp;
-
 use vars qw(
   @EXPORT_OK
   %EXPORT_TAGS
 use vars qw(
   @EXPORT_OK
   %EXPORT_TAGS
@@ -149,14 +148,14 @@ sub w_write_lock_file ($;$) {
     # and wait $timeout seconds for
     # references == 0 (no shared locks set)
     #
     # and wait $timeout seconds for
     # references == 0 (no shared locks set)
     #
-    &simple_lock ($filename,$timeout) or return;
+    &simple_lock ($filename,$timeout) or return 0;
     for (0..$timeout) {
       # lock reference counter
       # or fail
       #
       unless (&simple_lock (&reffile($filename),$timeout)) {
         &simple_unlock($filename,$timeout);
     for (0..$timeout) {
       # lock reference counter
       # or fail
       #
       unless (&simple_lock (&reffile($filename),$timeout)) {
         &simple_unlock($filename,$timeout);
-        return;
+        return 0;
       }
 
       # ready if we have no shared locks
       }
 
       # ready if we have no shared locks
@@ -168,7 +167,7 @@ sub w_write_lock_file ($;$) {
       #
       unless (&simple_unlock (&reffile($filename),$timeout)) {
         &simple_unlock($filename,$timeout);
       #
       unless (&simple_unlock (&reffile($filename),$timeout)) {
         &simple_unlock($filename,$timeout);
-        return;
+        return 0;
       }
       sleep(1);
     }
       }
       sleep(1);
     }
@@ -383,7 +382,7 @@ sub x_write_lock_file ($;$) {
     # and wait $timeout seconds for
     # references == 0 (no shared locks set)
     #
     # and wait $timeout seconds for
     # references == 0 (no shared locks set)
     #
-    &simple_lock ($filename,$timeout) or return;
+    &simple_lock ($filename,$timeout) or return 0;
     for (0..$timeout) {
 
       # lock reference counter
     for (0..$timeout) {
 
       # lock reference counter
@@ -391,7 +390,7 @@ sub x_write_lock_file ($;$) {
       #
       unless (&simple_lock (&reffile($filename),$timeout)) {
         &simple_unlock($filename,$timeout);
       #
       unless (&simple_lock (&reffile($filename),$timeout)) {
         &simple_unlock($filename,$timeout);
-        return;
+        return 0;
       }
 
       # ready if we have no shared locks
       }
 
       # ready if we have no shared locks
@@ -403,7 +402,7 @@ sub x_write_lock_file ($;$) {
       #
       unless (&simple_unlock (&reffile($filename),$timeout)) {
         &simple_unlock($filename,$timeout);
       #
       unless (&simple_unlock (&reffile($filename),$timeout)) {
         &simple_unlock($filename,$timeout);
-        return;
+        return 0;
       }
       sleep(1);
     }
       }
       sleep(1);
     }
@@ -556,6 +555,7 @@ sub masterlockfile ($) {
   &lockfile(&masterfile($_[0]));
 }
 sub masterfile ($) {
   &lockfile(&masterfile($_[0]));
 }
 sub masterfile ($) {
+  confess unless defined $_[0];
   "$_[0].master";
 }
 
   "$_[0].master";
 }
 
@@ -843,4 +843,4 @@ BEGIN {
 
 #
 #
 
 #
 #
-### end of Lock ################################################################
+### end of Lock ################################################################
\ No newline at end of file

patrick-canterino.de