class Puma::Server

def process_client(client)

Return true if one or more requests were processed.

returning.
indicates that it supports keep alive, wait for another request before
This method supports HTTP Keep-Alive so it may, depending on if the client

This method is called from a ThreadPool worker thread.

or queue the connection in the Reactor if no request is available.
Given a connection on +client+, handle the incoming requests,
def process_client(client)
  # Advertise this server into the thread
  Thread.current[THREAD_LOCAL_KEY] = self
  clean_thread_locals = @options[:clean_thread_locals]
  close_socket = true
  requests = 0
  begin
    if @queue_requests &&
      !client.eagerly_finish
      client.set_timeout(@first_data_timeout)
      if @reactor.add client
        close_socket = false
        return false
      end
    end
    with_force_shutdown(client) do
      client.finish(@first_data_timeout)
    end
    while true
      @requests_count += 1
      case handle_request(client, requests + 1)
      when false
        break
      when :async
        close_socket = false
        break
      when true
        ThreadPool.clean_thread_locals if clean_thread_locals
        requests += 1
        # As an optimization, try to read the next request from the
        # socket for a short time before returning to the reactor.
        fast_check = @status == :run
        # Always pass the client back to the reactor after a reasonable
        # number of inline requests if there are other requests pending.
        fast_check = false if requests >= @max_fast_inline &&
          @thread_pool.backlog > 0
        next_request_ready = with_force_shutdown(client) do
          client.reset(fast_check)
        end
        unless next_request_ready
          break unless @queue_requests
          client.set_timeout @persistent_timeout
          if @reactor.add client
            close_socket = false
            break
          end
        end
      end
    end
    true
  rescue StandardError => e
    client_error(e, client)
    # The ensure tries to close +client+ down
    requests > 0
  ensure
    client.io_buffer.reset
    begin
      client.close if close_socket
    rescue IOError, SystemCallError
      Puma::Util.purge_interrupt_queue
      # Already closed
    rescue StandardError => e
      @log_writer.unknown_error e, nil, "Client"
    end
  end
end