From 2a374b957eec3bab6ef6858e723c3b14d7289631 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Mon, 14 Dec 2015 17:20:17 -0800 Subject: [PATCH] Correct off-by-one error in counter. The counter should be incremented/decremented after testing its value, not before. --- Supporters/lib/Supporters.pm | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Supporters/lib/Supporters.pm b/Supporters/lib/Supporters.pm index 7268e68..ec20b9c 100644 --- a/Supporters/lib/Supporters.pm +++ b/Supporters/lib/Supporters.pm @@ -411,9 +411,7 @@ sub _beginWork($) { die "_beginWork: Mismatched begin_work/commit pair in API implementation" if ($NESTED_TRANSACTION_COUNTER < 0); - $NESTED_TRANSACTION_COUNTER++; - - $self->dbh->begin_work() if ($NESTED_TRANSACTION_COUNTER == 1); + $self->dbh->begin_work() if ($NESTED_TRANSACTION_COUNTER++ == 1); } =item _commit() @@ -438,9 +436,7 @@ sub _commit($) { die "_commit: Mismatched begin_work/commit pair in API implementation" if ($NESTED_TRANSACTION_COUNTER <= 0); - $NESTED_TRANSACTION_COUNTER--; - - $self->dbh->commit() if ($NESTED_TRANSACTION_COUNTER == 0); + $self->dbh->commit() if ($NESTED_TRANSACTION_COUNTER-- == 0); } =back