deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core] Core: Prevent multiple driver class loading (DTACLOUD-290)
Date Wed, 01 Aug 2012 11:40:25 GMT
From: Michal Fojtik <mfojtik@redhat.com>

This patch should prevent memory leaking caused
by repetetive driver loading on every request.

Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/lib/deltacloud/helpers/driver_helper.rb |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/server/lib/deltacloud/helpers/driver_helper.rb b/server/lib/deltacloud/helpers/driver_helper.rb
index 5c5e7c6..ab0e3c6 100644
--- a/server/lib/deltacloud/helpers/driver_helper.rb
+++ b/server/lib/deltacloud/helpers/driver_helper.rb
@@ -42,14 +42,14 @@ module Deltacloud::Helpers
         m = Deltacloud::Drivers.const_get(driver_class_name)
         m.const_get(driver_class_name + "Driver").new
       rescue NameError
-        raise "[ERROR] The driver class name is not defined as #{driver_class_name}Driver"
+        nil
       end
     end
 
     def driver
       $:.unshift File.join(File.dirname(__FILE__), '..', '..')
       begin
-        require_relative driver_source_name
+        require_relative(driver_source_name) unless driver_class
         driver_class
       rescue LoadError => e
         raise "[ERROR] The driver '#{driver_name}' is unknown or not installed (#{driver_source_name})\n"
+
-- 
1.7.10.2


Mime
View raw message