]> git.donarmstrong.com Git - debbugs.git/commitdiff
[project @ 2003-05-26 12:30:04 by cjwatson]
authorcjwatson <>
Mon, 26 May 2003 19:30:04 +0000 (11:30 -0800)
committercjwatson <>
Mon, 26 May 2003 19:30:04 +0000 (11:30 -0800)
The uses of writebug in process shouldn't unfilelock immediately; they go
on to do other things with the bug and need to hold the lock. Remove the
automatic unfilelock from writebug and introduce a new 'unlockwritebug'
function (by analogy with 'lockreadbug'), used in service.

Make unfilelock produce a more sensible error message when the @filelocks
stack is empty, in case this ever happens again.

scripts/errorlib.in
scripts/service.in

index 0d13b7b83f457823bbd802ab354e67ec0d5a931b..20a09807d1690c95a25801f3239662439f7022f4 100755 (executable)
@@ -1,5 +1,5 @@
 # -*- perl -*-
-# $Id: errorlib.in,v 1.25 2003/05/25 18:25:37 cjwatson Exp $
+# $Id: errorlib.in,v 1.26 2003/05/26 12:30:04 cjwatson Exp $
 
 sub F_SETLK { 6; } sub F_WRLCK{ 1; }
 $flockstruct= 'sslll'; # And there ought to be something for this too.
@@ -115,6 +115,10 @@ sub writebug {
           "$data->{severity}\n".
           "$data->{versions}\n".
           "$data->{fixed_versions}\n");
+}
+
+sub unlockwritebug {
+    writebug(@_);
     &unfilelock;
 }
 
@@ -150,6 +154,10 @@ sub filelock {
 }
 
 sub unfilelock {
+    if (@filelocks == 0) {
+        warn "unfilelock called with no active filelocks!\n";
+        return;
+    }
     local ($lockfile) = pop(@filelocks);
     pop(@cleanups);
     eval 'close(FLOCK'.($#filelocks+1).');' || warn "failed to close lock file $lockfile: $!";
index 7813c3c41baaa82db7b3d7b4615386ccdefcb5f4..765d6e017460e9dc33edd484776e6b8577a59dab 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# $Id: service.in,v 1.74 2003/05/03 21:10:40 doogie Exp $
+# $Id: service.in,v 1.75 2003/05/26 12:30:04 cjwatson Exp $
 # ^ more or less ^
 #
 # Usage: service <code>.nn
@@ -891,7 +891,7 @@ sub savebug {
           "\3\n".
           "\7\n",@{escapelog(@log)},"\n\3\n") || &quit("writing db-h/$hash/$ref.log: $!");
     close(L) || &quit("closing db-h/$hash/$ref.log: $!");
-    writebug($ref, $data);
+    unlockwritebug($ref, $data);
     $lowstate= "idle";
     &dlex("savebug");
 }