Repository: puma/puma
File: lib/puma/cluster.rb (Ruby)

Code before:
        booted = false
        in_phased_restart = false
        workers_not_booted = @options[:workers]

        while @status == :run
          begin
            if all_workers_idle_timed_out?
              log "- All workers reached idle timeout"
              break
            end

            if @phased_restart
              start_phased_restart
              @phased_restart = false
              in_phased_restart = true
              workers_not_booted = @options[:workers]
            end

            check_workers

            if read.wait_readable([0, @next_check - Time.now].max)
              req = read.read_nonblock(1)
              next unless req

              if req == Puma::Const::PipeRequest::WAKEUP
                next @next_check = Time.now
              end

              result = read.gets
              pid = result.to_i

              if req == Puma::Const::PipeRequest::BOOT || req == Puma::Const::PipeRequest::FORK
                pid, idx = result.split(':').map(&:to_i)
                w = worker_at idx
                w.pid = pid if w.pid.nil?
              end

              if w = @workers.find { |x| x.pid == pid }
                case req
                when Puma::Const::PipeRequest::BOOT
                  w.boot!
                  log "- Worker #{w.index} (PID: #{pid}) booted in #{w.uptime.round(2)}s, phase: #{w.phase}"
                  @next_check = Time.now
                  workers_not_booted -= 1
                when Puma::Const::PipeRequest::EXTERNAL_TERM
                  # external term, see worker method, Signal.trap "SIGTERM"
                  w.term!
                when Puma::Const::PipeRequest::TERM
                  w.term unless w.term?
                when Puma::Const::PipeRequest::PING
                  status = result.sub(/^\d+/,'').chomp

Review comment (suggestion):
WDYT?

```suggestion
                @next_check = Time.now
                next
```

It would be more like how it was before this change (Yeah, I know, it looks like nothing it using the result from the iterations of this `while` loop, so `next @next_check = Time.now` doesn't hurt but maybe it makes someone think more about it than they need to, like I did now 😄 )

Code after:
        booted = false
        in_phased_restart = false
        workers_not_booted = @options[:workers]

        while @status == :run
          begin
            if all_workers_idle_timed_out?
              log "- All workers reached idle timeout"
              break
            end

            if @phased_restart
              start_phased_restart
              @phased_restart = false
              in_phased_restart = true
              workers_not_booted = @options[:workers]
            end

            check_workers

            if read.wait_readable([0, @next_check - Time.now].max)
              req = read.read_nonblock(1)
              next unless req

              if req == Puma::Const::PipeRequest::WAKEUP
                @next_check = Time.now
                next
              end

              result = read.gets
              pid = result.to_i

              if req == Puma::Const::PipeRequest::BOOT || req == Puma::Const::PipeRequest::FORK
                pid, idx = result.split(':').map(&:to_i)
                w = worker_at idx
                w.pid = pid if w.pid.nil?
              end

              if w = @workers.find { |x| x.pid == pid }
                case req
                when Puma::Const::PipeRequest::BOOT
                  w.boot!
                  log "- Worker #{w.index} (PID: #{pid}) booted in #{w.uptime.round(2)}s, phase: #{w.phase}"
                  @next_check = Time.now
                  workers_not_booted -= 1
                when Puma::Const::PipeRequest::EXTERNAL_TERM
                  # external term, see worker method, Signal.trap "SIGTERM"
                  w.term!
                when Puma::Const::PipeRequest::TERM
                  w.term unless w.term?
                when Puma::Const::PipeRequest::PING