diff --git a/HISTORY.md b/HISTORY.md index 506e7ad..f12205f 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -5,6 +5,11 @@ Head ======= - None yet. +1.0.1 +======= +- Close orphan clients outside of synchonize +- Freeze alarm message + 1.0.0 ======= - Allow setting a default client for HotTub::Sessions diff --git a/hot_tub.gemspec b/hot_tub.gemspec index 0a334a5..0b23efd 100644 --- a/hot_tub.gemspec +++ b/hot_tub.gemspec @@ -14,7 +14,7 @@ Gem::Specification.new do |s| s.rubyforge_project = "hot_tub" - s.add_development_dependency "rspec" + s.add_development_dependency "rspec", "~> 3.0" s.add_development_dependency "rspec-autotest" s.add_development_dependency "autotest" s.add_development_dependency "sinatra" diff --git a/lib/hot_tub/pool.rb b/lib/hot_tub/pool.rb index d112981..9acf8af 100644 --- a/lib/hot_tub/pool.rb +++ b/lib/hot_tub/pool.rb @@ -234,7 +234,7 @@ def max_size=max_size private - ALARM_MESSAGE = "Could not fetch a free client in time. Consider increasing your pool size." + ALARM_MESSAGE = "Could not fetch a free client in time. Consider increasing your pool size.".freeze def raise_alarm message = ALARM_MESSAGE @@ -242,22 +242,28 @@ def raise_alarm raise Timeout, message end + def close_orphan(clnt) + HotTub.logger.info "[HotTub] An orphaned client attempted to return to #{@name}." if HotTub.log_trace? + close_client(clnt) + end + # Safely add client back to pool, only if # that client is registered def push(clnt) if clnt + orphaned = false @mutex.synchronize do begin if !@shutdown && @_out.delete(clnt) @_pool << clnt else - close_client(clnt) - HotTub.logger.info "[HotTub] An orphaned client attempted to return to #{@name}." if HotTub.log_trace? + orphaned = true end ensure @cond.signal end end + close_orphan(clnt) if orphaned reap! if @blocking_reap end nil