Skip to content

Commit

Permalink
Reset workers deadline on instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Jun 29, 2023
1 parent ec8e65b commit 3f76ba7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/pitchfork/shared_memory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def value=(value)
end
end

def mold_tick
def mold_deadline
self[MOLD_TICK_OFFSET]
end

def worker_tick(worker_nr)
def worker_deadline(worker_nr)
self[WORKER_TICK_OFFSET + worker_nr]
end

Expand Down
6 changes: 4 additions & 2 deletions lib/pitchfork/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def initialize(nr, pid: nil, generation: 0)
@exiting = false
@requests_count = 0
if nr
@deadline_drop = SharedMemory.worker_tick(nr)
@deadline_drop = SharedMemory.worker_deadline(nr)
self.deadline = 0
else
promoted!
end
Expand Down Expand Up @@ -92,7 +93,8 @@ def promote!
def promoted!
@mold = true
@nr = nil
@deadline_drop = SharedMemory.mold_tick
@deadline_drop = SharedMemory.mold_deadline
self.deadline = 0
self
end

Expand Down

0 comments on commit 3f76ba7

Please sign in to comment.