Permalink
Browse files

Explicitly convert FixNums to Integers in time comparison.

  • Loading branch information...
1 parent ffe7c20 commit cd0e15e82c1d43ca35ca0e2863f7f251ff29e851 @alexgb committed Jan 13, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/delayed/backend/data_mapper.rb
@@ -30,7 +30,7 @@ def self.find_available(worker_name, limit = 5, max_run_time = Worker.max_run_ti
simple_conditions[:priority.gte] = Worker.min_priority if Worker.min_priority
simple_conditions[:priority.lte] = Worker.max_priority if Worker.max_priority
simple_conditions[:queue] = Worker.queues if Worker.queues.any?
- lockable = (all(:run_at.lte => db_time_now) & (all(:locked_at => nil) | all(:locked_at.lt => db_time_now - max_run_time)) | all(:locked_by => worker_name)) & all(:failed_at => nil)
+ lockable = (all(:run_at.lte => db_time_now) & (all(:locked_at => nil) | all(:locked_at.lt => db_time_now - max_run_time.to_i)) | all(:locked_by => worker_name)) & all(:failed_at => nil)
lockable.all(simple_conditions)
end
@@ -48,7 +48,7 @@ def lock_exclusively!(max_run_time, worker = worker_name)
# DM doesn't give us the number of rows affected by a collection update
# so we have to circumvent some niceness in DM::Collection here
collection = if locked_by != worker
- (self.class.all(:id => id) & (self.class.all(:locked_at => nil) | self.class.all(:locked_at.lt => now - max_run_time)) & self.class.all(:run_at.lte => now))
+ (self.class.all(:id => id) & (self.class.all(:locked_at => nil) | self.class.all(:locked_at.lt => now - max_run_time.to_i)) & self.class.all(:run_at.lte => now))
else
self.class.all(:id => id, :locked_by => worker)
end

0 comments on commit cd0e15e

Please sign in to comment.