module Dalli::Socket::InstanceMethods
def append_to_buffer?(result)
def append_to_buffer?(result) raise Timeout::Error, "IO timeout: #{logged_options.inspect}" if nonblock_timed_out?(result) raise Errno::ECONNRESET, "Connection reset: #{logged_options.inspect}" unless result !WAIT_RCS.include?(result) end
def logged_options
def logged_options options.except(*FILTERED_OUT_OPTIONS) end
def nonblock_timed_out?(result)
def nonblock_timed_out?(result) return true if result == :wait_readable && !wait_readable(options[:socket_timeout]) # TODO: Do we actually need this? Looks to be only used in read_nonblock result == :wait_writable && !wait_writable(options[:socket_timeout]) end
def read_available
def read_available value = +'' loop do result = read_nonblock(8196, exception: false) break if WAIT_RCS.include?(result) raise Errno::ECONNRESET, "Connection reset: #{logged_options.inspect}" unless result value << result end value end
def readfull(count)
def readfull(count) value = String.new(capacity: count + 1) loop do result = read_nonblock(count - value.bytesize, exception: false) value << result if append_to_buffer?(result) break if value.bytesize == count end value end