You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2012/10/18 21:43:14 UTC

[PATCH core 3/3] Replaced YAML.load with YAML.load_file (DTACLOUD-347)

From: Michal Fojtik <mf...@redhat.com>

* Fix nasty memory leaking issue under MRI 1.9.3p194

Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 server/lib/deltacloud/drivers.rb                  | 2 +-
 server/lib/deltacloud/drivers/mock/mock_client.rb | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/server/lib/deltacloud/drivers.rb b/server/lib/deltacloud/drivers.rb
index 14e7ee0..4e0f127 100644
--- a/server/lib/deltacloud/drivers.rb
+++ b/server/lib/deltacloud/drivers.rb
@@ -26,7 +26,7 @@ module Deltacloud
         Thread::current[:drivers] = {}
         top_srcdir = File.join(File.dirname(__FILE__), '..', '..')
         Dir[File.join(top_srcdir, 'config', 'drivers', '*.yaml')].each do |driver_file|
-          Thread::current[:drivers].merge!(YAML::load(File::read(driver_file)))
+          Thread::current[:drivers].merge!(YAML::load_file(driver_file))
         end
       end
       Thread::current[:drivers]
diff --git a/server/lib/deltacloud/drivers/mock/mock_client.rb b/server/lib/deltacloud/drivers/mock/mock_client.rb
index 817ae0b..c6dd464 100644
--- a/server/lib/deltacloud/drivers/mock/mock_client.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_client.rb
@@ -56,10 +56,10 @@ module Deltacloud::Drivers::Mock
       files(collection).map { |f| File::basename(f, ".yml") }
     end
 
-    def load(collection, id)
+    def load_collection(collection, id)
       fname = file(collection, id)
       begin
-        YAML.load(File.read(fname))
+        YAML.load_file(fname)
       rescue Errno::ENOENT
         nil
       end
@@ -73,12 +73,12 @@ module Deltacloud::Drivers::Mock
     # Return the object with id +id+ of class +klass+ from the collection
     # derived from the classes name
     def build(klass, id)
-      klass.new(load(collection_name(klass), id))
+      klass.new(load_collection(collection_name(klass), id))
     end
 
     # Return an array of hashes of all the resources in the collection
     def load_all(collection)
-      members(collection).map { |id| load(collection, id) }
+      members(collection).map { |id| load_collection(collection, id) }
     end
 
     # Return an array of model objects of the resources in the collection
-- 
1.7.12.1