From 530fa81af8a7dd6319009bc5be7d6e70ff427473 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Sun, 15 Jul 2012 16:00:45 -0700 Subject: [PATCH] fix lack of unlocking in process before we start control --- scripts/process | 14 ++++++++++---- t/14_control_at_submit.t | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/scripts/process b/scripts/process index e5bec48..5b7175f 100755 --- a/scripts/process +++ b/scripts/process @@ -275,12 +275,14 @@ $subject =~ s/^Re:\s*//i; $_= $subject."\n"; if (not defined $tryref and m/^Bug ?\#(\d+)\D/i) { $tryref = $1 if $1 > 0; } +my $locks = 0; my $data; if (defined $tryref) { - my $bfound; - ($bfound, $data)= &lockreadbugmerge($tryref); - if ($bfound and not $data->{archived}) { - $ref= $tryref; + my $locks_recv; + ($locks_recv, $data)= &lockreadbugmerge($tryref); + $locks += $locks_recv; + if ($locks_recv and not $data->{archived}) { + $ref= $tryref; } else { &sendmessage(create_mime_message( [From => "$gMaintainerEmail ($gProject $gBug Tracking System)", @@ -408,8 +410,10 @@ if ($codeletter eq 'D' || $codeletter eq 'F') for $ref (@process) { if ($ref != $orgref) { &unfilelock; + $locks--; $data = &lockreadbug($ref) || die "huh ? $ref from $orgref out of ".join(' ',@process); + $locks++; } $data->{done}= $set_done if defined($set_done); $data->{forwarded}= $set_forwarded if defined($set_forwarded); @@ -956,6 +960,8 @@ if (not exists $header{'x-debbugs-no-ack'} and } appendlog($ref,$msg); +# unlock the locks we have received +while ($locks--) {unfilelock();} ## handle control messages at this point, immediately before finishing my %clonebugs = (-1 => $ref); diff --git a/t/14_control_at_submit.t b/t/14_control_at_submit.t index 38ea9d8..6688f53 100644 --- a/t/14_control_at_submit.t +++ b/t/14_control_at_submit.t @@ -1,7 +1,7 @@ # -*- mode: cperl;-*- # $Id: 05_mail.t,v 1.1 2005/08/17 21:46:17 don Exp $ -use Test::More tests => 120; +use Test::More tests => 122; use warnings; use strict; @@ -140,6 +140,21 @@ ok(system('sh','-c','find '.$sendmail_dir.q( -type f | xargs grep -q "Subject: P $status = read_bug(bug=>2); ok($status->{subject} eq 'this is a new title','bug 2 retitled at submit@ time'); +send_message(to => '1@bugs.something', + headers => [To => '1@bugs.something', + From => 'foo@bugs.something', + Subject => 'Testing control at 1@bugs.something', + ], + body => <1); +ok($status->{subject} eq 'this is now the title of bug 1','bug 1 retitled at 1@ time'); + # now we're going to go through and methododically test all of the control commands. -- 2.39.2