[1/2] testbot/VMs: Turn VM::Hypervisors into a singleton so we maintain a single connection per hypervisor as was intended.
Francois Gouget
fgouget at codeweavers.com
Fri Sep 27 12:58:26 CDT 2013
---
testbot/lib/WineTestBot/VMs.pm | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/testbot/lib/WineTestBot/VMs.pm b/testbot/lib/WineTestBot/VMs.pm
index 33ed5c0..3fcb644 100644
--- a/testbot/lib/WineTestBot/VMs.pm
+++ b/testbot/lib/WineTestBot/VMs.pm
@@ -48,13 +48,17 @@ require Exporter;
@EXPORT_OK = qw(new);
+my $Singleton;
sub new($)
{
my ($class) = @_;
- my $self = {};
- $self = bless $self, $class;
- return $self;
+ if (!defined $Singleton)
+ {
+ $Singleton = {};
+ $Singleton = bless $Singleton, $class;
+ }
+ return $Singleton;
}
=pod
@@ -75,8 +79,8 @@ sub GetHypervisor($$)
my $Key = $URI || "";
if (!defined $self->{$Key})
{
- eval { $self->{$Key} = Sys::Virt->new(uri => $URI); };
- return ($@->message(), undef) if ($@);
+ eval { $self->{$Key} = Sys::Virt->new(uri => $URI); };
+ return ($@->message(), undef) if ($@);
}
return (undef, $self->{$Key});
--
1.8.4.rc3
More information about the wine-patches
mailing list