Skip to content

Commit d495eff

Browse files
committed
Fix #_write_to_socket in connection
By placing the NBIO_READ_EXCEPTIONS above the NBIO_WRITE_EXCEPTIONS, an Errno::EWOULDBLOCK or Errno::EAGAIN would trigger a wait for the socket to be readable. This is causing timeout errors in our testing. When calling #write_nonblock, the appropriate action is to wait for the socket to be writable, not readable. Ensuring that we handle the write exceptions before the read exceptions accomplishes this.
1 parent 27759c0 commit d495eff

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/redis/connection/ruby.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ def _write_to_socket(data)
104104
begin
105105
write_nonblock(data)
106106

107-
rescue *NBIO_READ_EXCEPTIONS
108-
if IO.select([self], nil, nil, @write_timeout)
107+
rescue *NBIO_WRITE_EXCEPTIONS
108+
if IO.select(nil, [self], nil, @write_timeout)
109109
retry
110110
else
111111
raise Redis::TimeoutError
112112
end
113-
rescue *NBIO_WRITE_EXCEPTIONS
114-
if IO.select(nil, [self], nil, @write_timeout)
113+
rescue *NBIO_READ_EXCEPTIONS
114+
if IO.select([self], nil, nil, @write_timeout)
115115
retry
116116
else
117117
raise Redis::TimeoutError

0 commit comments

Comments
 (0)