-
Notifications
You must be signed in to change notification settings - Fork 93
Avoid SSLSocket leaks by setting sync_close by default #135
Avoid SSLSocket leaks by setting sync_close by default #135
Conversation
|
||
def initialize(io, ctx = OpenSSL::SSL::SSLContext.new) | ||
super() | ||
@context = ctx | ||
@socket = OpenSSL::SSL::SSLSocket.new(::IO.try_convert(io), @context) | ||
@socket.sync_close = true if @socket.respond_to?(:sync_close=) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need the delegator if you're calling sync_close
on @socket
directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The delegator is in case people want to override the behavior primarily. I think the odds of someone wanting to do that is nil, but people do strange things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like for Celluloid::IO::SSLSocket
to be as close to a duck type of OpenSSL::SSL::SSLSocket
as possible, and that includes delegating this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad on confusing the intent here, focusing only on function. Clear to merge then once the blizzard of tests is subdued to something sane.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem! I agree on it being ugly. I hate the sync_close setter but Ruby made it default off so :(
Sent from my iPhone
On Apr 6, 2015, at 11:43, digitalextremist [email protected] wrote:
In lib/celluloid/io/ssl_socket.rb:
def initialize(io, ctx = OpenSSL::SSL::SSLContext.new) super() @context = ctx @socket = OpenSSL::SSL::SSLSocket.new(::IO.try_convert(io), @context)
My bad on confusing the intent here, focusing only on function. Clear to merge then once the blizzard of tests is subdued to something sane.@socket.sync_close = true if @socket.respond_to?(:sync_close=)
—
Reply to this email directly or view it on GitHub.
Oh my, the build failures 😢 They all seem unrelated at least, but... |
Uhhh. #134? |
Yeah. These are rspec syntax/behavior failures. |
Sorry, not clear but what's the problem? Does #134 block until this goes green? |
There's an |
I wouldn't be opposed to landing this despite the spec failures |
Yeah, I'm just going to merge this now and fiddle with tests separately. |
Avoid SSLSocket leaks by setting sync_close by default
@digitalextremist transpec helps a lot to update specs... |
[ haha, now that all the tests are current :) ] |
@digitalextremist - yeah, life would be hard without transpec. There are a few tricks, though (for outdated projects):
|
@tarcieri