From: cjwatson <> Date: Mon, 26 May 2003 19:30:04 +0000 (-0800) Subject: [project @ 2003-05-26 12:30:04 by cjwatson] X-Git-Tag: release/2.6.0~884 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f44f00588cbc07ac3303c4bf420bd258e89e9fc8;p=debbugs.git [project @ 2003-05-26 12:30:04 by cjwatson] 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. --- diff --git a/scripts/errorlib.in b/scripts/errorlib.in index 0d13b7b8..20a09807 100755 --- a/scripts/errorlib.in +++ b/scripts/errorlib.in @@ -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: $!"; diff --git a/scripts/service.in b/scripts/service.in index 7813c3c4..765d6e01 100755 --- a/scripts/service.in +++ b/scripts/service.in @@ -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 .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"); }