From 3b473ed40822a72f4f9e4892dab231affd275fd9 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 4 Mar 2010 19:35:30 +0000 Subject: [PATCH] Clarify order of bound manipulations so it is not temporarily exceeded. --- perl/lib/Thrasher/ConnectionManager.pm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/perl/lib/Thrasher/ConnectionManager.pm b/perl/lib/Thrasher/ConnectionManager.pm index a54cbc0..181f32b 100644 --- a/perl/lib/Thrasher/ConnectionManager.pm +++ b/perl/lib/Thrasher/ConnectionManager.pm @@ -334,15 +334,22 @@ sub service_request { confess "Undefined closure passed to service_request."; } log("Servicing connection request."); + my $orig_simultaneous_connect_bound = $SIMULTANEOUS_CONNECT_BOUND; + $SIMULTANEOUS_CONNECT_BOUND--; eval { $closure->(); }; if ($@) { - log("Failure in connection callback: $@"); - } - else { - $SIMULTANEOUS_CONNECT_BOUND--; + log("Failure in connection request closure: $@"); + + # $closure may or may not have called + # connection_{success,failure} before dying. Reset the bound + # (instead of incrementing) in case it did. + $SIMULTANEOUS_CONNECT_BOUND = $orig_simultaneous_connect_bound; } + # Else *rely* on $closure to increment $SIMULTANEOUS_CONNECT_BOUND. + # Can't detect here if connection_{success,failure} will be called + # later or synchronously. } # connection_failure($local_only) -- 2.11.4.GIT