From: Peter Rabbitson Date: Thu, 26 May 2016 15:02:06 +0000 (+0200) Subject: Prevent CLONE from potentially running more than once X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=04c1a07034f365766217376a0ea194f14fb209a9;p=dbsrgits%2FDBIx-Class.git Prevent CLONE from potentially running more than once Argh, another thing I didn't know about iThreads: CLONE will run for every package defining *or inheriting* it. Sigh... --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 302bcca..6c2940c 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -251,7 +251,7 @@ sub new { undef; } - sub CLONE { + sub DBIx::Class::__DBI_Storage_iThreads_handler__::CLONE { # As per DBI's recommendation, DBIC disconnects all handles as # soon as possible (DBIC will reconnect only on demand from within # the thread) diff --git a/lib/DBIx/Class/Storage/DBI/Cursor.pm b/lib/DBIx/Class/Storage/DBI/Cursor.pm index 6ea7004..1558559 100644 --- a/lib/DBIx/Class/Storage/DBI/Cursor.pm +++ b/lib/DBIx/Class/Storage/DBI/Cursor.pm @@ -72,7 +72,7 @@ Returns a new L object. return $self; } - sub CLONE { + sub DBIx::Class::__DBI_Cursor_iThreads_handler__::CLONE { for (keys %cursor_registry) { # once marked we no longer care about them, hence no # need to keep in the registry, left alone renumber the diff --git a/lib/DBIx/Class/_Util.pm b/lib/DBIx/Class/_Util.pm index 31f038f..da0d49b 100644 --- a/lib/DBIx/Class/_Util.pm +++ b/lib/DBIx/Class/_Util.pm @@ -437,7 +437,7 @@ sub is_exception ($) { { my $destruction_registry = {}; - sub CLONE { + sub DBIx::Class::__Util_iThreads_handler__::CLONE { %$destruction_registry = map { (defined $_) ? ( refaddr($_) => $_ ) diff --git a/t/lib/DBICTest/Util/LeakTracer.pm b/t/lib/DBICTest/Util/LeakTracer.pm index 8e2e6e8..4873d77 100644 --- a/t/lib/DBICTest/Util/LeakTracer.pm +++ b/t/lib/DBICTest/Util/LeakTracer.pm @@ -73,7 +73,7 @@ sub populate_weakregistry { } # Regenerate the slots names on a thread spawn -sub CLONE { +sub DBICTest::__LeakTracer_iThreads_handler__::CLONE { my @individual_regs = grep { scalar keys %{$_||{}} } values %reg_of_regs; %reg_of_regs = ();