Francois Gouget : testbot/VMs: Turn VM:: Hypervisors into a singleton so we maintain a single connection per hypervisor as was intended .

Alexandre Julliard julliard at winehq.org
Mon Sep 30 13:43:26 CDT 2013


Module: tools
Branch: master
Commit: b9435d67f2b924d1d3e66e052a6375c3155b74e9
URL:    http://source.winehq.org/git/tools.git/?a=commit;h=b9435d67f2b924d1d3e66e052a6375c3155b74e9

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Fri Sep 27 19:58:26 2013 +0200

testbot/VMs: Turn VM::Hypervisors into a singleton so we maintain a single connection per hypervisor as was intended.

---

 testbot/lib/WineTestBot/VMs.pm |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/testbot/lib/WineTestBot/VMs.pm b/testbot/lib/WineTestBot/VMs.pm
index 2cfeb54..c92b534 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});




More information about the wine-cvs mailing list