Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Unreleased
- Fix cannot read response data included terminator `\r\n` when use meta protocol (matsubara0507)
- Support SERVER_ERROR response from Memcached as per the [memcached spec](https://github.com/memcached/memcached/blob/e43364402195c8e822bb8f88755a60ab8bbed62a/doc/protocol.txt#L172) (grcooper)
- Update Socket timeout handling to use Socket#timeout= when available (nickamorim)
- Remove Socket#readfull and replace with standard read method (grcooper)

3.2.8
==========
Expand Down
2 changes: 1 addition & 1 deletion lib/dalli/protocol/connection_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def read_line
end

def read(count)
@sock.readfull(count)
@sock.read(count)
rescue SystemCallError, *TIMEOUT_ERRORS, EOFError => e
error_on_request!(e)
end
Expand Down
27 changes: 1 addition & 26 deletions lib/dalli/socket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,7 @@ module Socket
# Common methods for all socket implementations.
##
module InstanceMethods
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

WAIT_RCS = %i[wait_writable wait_readable].freeze
def read_available
value = +''
loop do
Expand All @@ -34,22 +25,6 @@ def read_available
value
end

WAIT_RCS = %i[wait_writable wait_readable].freeze

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 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

FILTERED_OUT_OPTIONS = %i[username password].freeze
def logged_options
options.reject { |k, _| FILTERED_OUT_OPTIONS.include? k }
Expand Down
Loading