deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Lutterkort <lut...@redhat.com>
Subject Re: [PATCH core] Core: Prevent multiple driver class loading (DTACLOUD-290)
Date Thu, 02 Aug 2012 02:30:26 GMT
On Wed, 2012-08-01 at 13:40 +0200, mfojtik@redhat.com wrote:
> 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__), '..', '..')

This here extends $: every time we load a driver. Shouldn't lib/ be on
$: already anyway ?

>        begin
> -        require_relative driver_source_name
> +        require_relative(driver_source_name) unless driver_class

I don't see how this can leak .. require only loads of the file hasn't
been loaded already.

David



Mime
View raw message