lib/drbman/drb_pool.rb in royw-drbman-0.0.4 vs lib/drbman/drb_pool.rb in royw-drbman-0.0.5

- old
+ new

@@ -72,11 +72,21 @@ # find the next available object # @return [DRbObject, nil] returns nil if no objects are available def next_object(mutex) object = nil mutex.synchronize do - object = @objects.select {|obj| !obj.in_use?}.first - object.in_use = true unless object.nil? + @objects.select {|obj| !obj.in_use?}.each do |obj| + unless obj.nil? + begin + obj.name # make sure we can still talk with drb server + obj.in_use = true + object = obj + break + rescue + object = nil + end + end + end end object end # Get a DRbObject to place into the pool