@@ -95,17 +95,13 @@ def self.wrap_with_ssl(io, tls_options = {}, timeout=nil)
95
95
conn . connect
96
96
end
97
97
rescue IO ::WaitReadable
98
- if IO . select ( [ conn ] , nil , nil , timeout )
99
- retry
100
- else
101
- raise Errno ::ETIMEDOUT , "OpenSSL connection read timeout"
102
- end
98
+ raise Errno ::ETIMEDOUT , "OpenSSL connection read timeout" unless
99
+ IO . select ( [ conn ] , nil , nil , timeout )
100
+ retry
103
101
rescue IO ::WaitWritable
104
- if IO . select ( nil , [ conn ] , nil , timeout )
105
- retry
106
- else
107
- raise Errno ::ETIMEDOUT , "OpenSSL connection write timeout"
108
- end
102
+ raise Errno ::ETIMEDOUT , "OpenSSL connection write timeout" unless
103
+ IO . select ( nil , [ conn ] , nil , timeout )
104
+ retry
109
105
end
110
106
111
107
# Doesn't work:
@@ -163,11 +159,9 @@ def setup_encryption(args, timeout=nil)
163
159
raise Net ::LDAP ::NoStartTLSResultError , "no start_tls result"
164
160
end
165
161
166
- if pdu . result_code . zero?
167
- @conn = self . class . wrap_with_ssl ( @conn , args [ :tls_options ] , timeout )
168
- else
169
- raise Net ::LDAP ::StartTLSError , "start_tls failed: #{ pdu . result_code } "
170
- end
162
+ raise Net ::LDAP ::StartTLSError ,
163
+ "start_tls failed: #{ pdu . result_code } " unless pdu . result_code . zero?
164
+ @conn = self . class . wrap_with_ssl ( @conn , args [ :tls_options ] , timeout )
171
165
else
172
166
raise Net ::LDAP ::EncMethodUnsupportedError , "unsupported encryption method #{ args [ :method ] } "
173
167
end
@@ -197,12 +191,10 @@ def queued_read(message_id)
197
191
198
192
# read messages until we have a match for the given message_id
199
193
while pdu = read
200
- if pdu . message_id == message_id
201
- return pdu
202
- else
203
- message_queue [ pdu . message_id ] . push pdu
204
- next
205
- end
194
+ return pdu if pdu . message_id == message_id
195
+
196
+ message_queue [ pdu . message_id ] . push pdu
197
+ next
206
198
end
207
199
208
200
pdu
0 commit comments