@@ -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
30
if RUBY_VERSION >= "1.9.3"
33
- NBIO_READ_EXCEPTIONS << IO ::WaitReadable
34
- NBIO_WRITE_EXCEPTIONS << IO ::WaitWritable
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_READ_EXCEPTIONS
108
- if IO . select ( [ self ] , nil , nil , @write_timeout )
108
+ rescue *NBIO_WRITE_EXCEPTIONS
109
+ if IO . select ( nil , [ self ] , nil , @write_timeout )
109
110
retry
110
111
else
111
112
raise Redis ::TimeoutError
112
113
end
113
- rescue *NBIO_WRITE_EXCEPTIONS
114
- if IO . select ( nil , [ self ] , nil , @write_timeout )
114
+ rescue *NBIO_READ_EXCEPTIONS
115
+ if IO . select ( [ self ] , nil , nil , @write_timeout )
115
116
retry
116
117
else
117
118
raise Redis ::TimeoutError
@@ -306,6 +307,7 @@ def self.connect(config)
306
307
raise ArgumentError , "SSL incompatible with unix sockets" if config [ :ssl ]
307
308
sock = UNIXSocket . connect ( config [ :path ] , config [ :connect_timeout ] )
308
309
elsif config [ :scheme ] == "rediss" || config [ :ssl ]
310
+ raise ArgumentError , "This library does not support SSL on Ruby < 1.9" if RUBY_VERSION < "1.9.3"
309
311
sock = SSLSocket . connect ( config [ :host ] , config [ :port ] , config [ :connect_timeout ] , config [ :ssl_params ] )
310
312
else
311
313
sock = TCPSocket . connect ( config [ :host ] , config [ :port ] , config [ :connect_timeout ] )
0 commit comments