-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,10 +79,31 @@ class OpenSSL::SSL::Socket | |
|
||
begin | ||
loop do | ||
ret = LibSSL.ssl_shutdown(@ssl) | ||
break if ret == 1 | ||
raise OpenSSL::SSL::Error.new(@ssl, ret, "SSL_shutdown") if ret < 0 | ||
# ret == 0, retry | ||
begin | ||
ret = LibSSL.ssl_shutdown(@ssl) | ||
break if ret == 1 | ||
raise OpenSSL::SSL::Error.new(@ssl, ret, "SSL_shutdown") if ret < 0 | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jhass
Author
Member
|
||
rescue e : Errno | ||
case e.errno | ||
when 0 | ||
# OpenSSL claimed an underlying syscall failed, but that didn't set any error state, | ||
# assume we're done | ||
break | ||
when Errno::EAGAIN | ||
# Ignore, shutdown did not complete yet | ||
else | ||
raise e | ||
end | ||
rescue e : OpenSSL::SSL::Error | ||
case e.error | ||
when .want_read?, .want_write? | ||
# Ignore, shutdown did not complete yet | ||
else | ||
raise e | ||
end | ||
end | ||
|
||
# ret == 0, retry, shutdown is not complete yet | ||
end | ||
rescue IO::Error | ||
ensure | ||
|
@jhass raising an exception and catching is pretty expensive. Can we maybe check this without raising an exception? It might be a bit uglier/longer, but maybe speed is more important here.