class Seahorse::Client::H2::Connection

def start(stream)

def start(stream)
  @mutex.synchronize {
    return if @socket_thread
    @socket_thread = Thread.new do
      while @socket && !@socket.closed?
        begin
          data = @socket.read_nonblock(@chunk_size)
          @h2_client << data
        rescue IO::WaitReadable
          begin
            unless IO.select([@socket], nil, nil, connection_read_timeout)
              self.debug_output('socket connection read time out')
              self.close!
            else
              # available, retry to start reading
              retry
            end
          rescue
            # error can happen when closing the socket
            # while it's waiting for read
            self.close!
          end
        rescue EOFError
          self.close!
        rescue => error
          self.debug_output(error.inspect)
          @errors << error
          self.close!
        end
      end
      @socket_thread = nil
    end
    @socket_thread.abort_on_exception = true
  }
end