From 0e1a6da0433fb83b3df7a9f5490cf57e31afdfcf Mon Sep 17 00:00:00 2001 From: "kirby@puppetlabs.com" Date: Wed, 23 Oct 2019 03:52:08 -0700 Subject: [PATCH] Simplify declaration of checkoutlock mutex This commit updates the way that checkoutlock is defined so it is not passed through bin/vmpooler. Without this change there's an unnecessary layer the mutex passes through. --- bin/vmpooler | 3 +-- lib/vmpooler/api.rb | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/vmpooler b/bin/vmpooler index 29a4e4e..b84a139 100755 --- a/bin/vmpooler +++ b/bin/vmpooler @@ -24,8 +24,7 @@ if torun.include? 'api' api = Thread.new do thr = Vmpooler::API.new redis = Vmpooler.new_redis(redis_host, redis_port, redis_password) - checkoutlock = Mutex.new - thr.helpers.configure(config, redis, metrics, checkoutlock) + thr.helpers.configure(config, redis, metrics) thr.helpers.execute! end torun_threads << api diff --git a/lib/vmpooler/api.rb b/lib/vmpooler/api.rb index 0b1fbe6..22bf64e 100644 --- a/lib/vmpooler/api.rb +++ b/lib/vmpooler/api.rb @@ -36,11 +36,11 @@ module Vmpooler use Vmpooler::API::Reroute use Vmpooler::API::V1 - def configure(config, redis, metrics, checkoutlock) + def configure(config, redis, metrics) self.settings.set :config, config self.settings.set :redis, redis self.settings.set :metrics, metrics - self.settings.set :checkoutlock, checkoutlock + self.settings.set :checkoutlock, Mutex.new end def execute!