@@ -27,11 +27,12 @@ module SocketMixin
2727 CRLF = "\r \n " . freeze
2828
2929 # 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 ]
3230 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 ]
3536 end
3637
3738 def initialize ( *args )
@@ -104,14 +105,14 @@ def _write_to_socket(data)
104105 begin
105106 write_nonblock ( data )
106107
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 )
109110 retry
110111 else
111112 raise Redis ::TimeoutError
112113 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 )
115116 retry
116117 else
117118 raise Redis ::TimeoutError
@@ -306,6 +307,7 @@ def self.connect(config)
306307 raise ArgumentError , "SSL incompatible with unix sockets" if config [ :ssl ]
307308 sock = UNIXSocket . connect ( config [ :path ] , config [ :connect_timeout ] )
308309 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"
309311 sock = SSLSocket . connect ( config [ :host ] , config [ :port ] , config [ :connect_timeout ] , config [ :ssl_params ] )
310312 else
311313 sock = TCPSocket . connect ( config [ :host ] , config [ :port ] , config [ :connect_timeout ] )
0 commit comments