@@ -27,11 +27,12 @@ module SocketMixin
27
27
CRLF = "\r \n " . freeze
28
28
29
29
# Exceptions raised during non-blocking I/O ops that require retrying the op
30
- NBIO_READ_EXCEPTIONS = [ Errno ::EWOULDBLOCK , Errno ::EAGAIN ]
31
- NBIO_WRITE_EXCEPTIONS = [ Errno ::EWOULDBLOCK , Errno ::EAGAIN ]
32
- if RUBY_VERSION >= "1.9.3"
33
- NBIO_READ_EXCEPTIONS << IO ::WaitReadable
34
- NBIO_WRITE_EXCEPTIONS << IO ::WaitWritable
30
+ if RUBY_VERSION >= "1.9.0"
31
+ NBIO_READ_EXCEPTIONS = [ IO ::WaitReadable ]
32
+ NBIO_WRITE_EXCEPTIONS = [ IO ::WaitWritable ]
33
+ else
34
+ NBIO_READ_EXCEPTIONS = [ Errno ::EWOULDBLOCK , Errno ::EAGAIN ]
35
+ NBIO_WRITE_EXCEPTIONS = [ Errno ::EWOULDBLOCK , Errno ::EAGAIN ]
35
36
end
36
37
37
38
def initialize ( *args )
@@ -104,14 +105,14 @@ def _write_to_socket(data)
104
105
begin
105
106
write_nonblock ( data )
106
107
107
- rescue *NBIO_WRITE_EXCEPTIONS
108
- if IO . select ( nil , [ self ] , nil , @write_timeout )
108
+ rescue *NBIO_READ_EXCEPTIONS
109
+ if IO . select ( [ self ] , nil , nil , @write_timeout )
109
110
retry
110
111
else
111
112
raise Redis ::TimeoutError
112
113
end
113
- rescue *NBIO_READ_EXCEPTIONS
114
- if IO . select ( [ self ] , nil , nil , @write_timeout )
114
+ rescue *NBIO_WRITE_EXCEPTIONS
115
+ if IO . select ( nil , [ self ] , nil , @write_timeout )
115
116
retry
116
117
else
117
118
raise Redis ::TimeoutError
0 commit comments