Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

Avoid SSLSocket leaks by setting sync_close by default #135

Merged
merged 1 commit into from
Apr 6, 2015

Conversation

zanker
Copy link

@zanker zanker commented Apr 6, 2015


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=)
Copy link
Member

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.

Copy link
Author

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Author

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)
  •    @socket.sync_close = true if @socket.respond_to?(:sync_close=)
    
    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.


Reply to this email directly or view it on GitHub.

@tarcieri
Copy link
Member

tarcieri commented Apr 6, 2015

Oh my, the build failures 😢

They all seem unrelated at least, but...

/cc @digitalextremist

@digitalextremist
Copy link
Member

Uhhh. #134?

@digitalextremist
Copy link
Member

Yeah. These are rspec syntax/behavior failures.

@zanker
Copy link
Author

zanker commented Apr 6, 2015

Sorry, not clear but what's the problem? Does #134 block until this goes green?

@digitalextremist
Copy link
Member

There's an rspec compatibility issue. I'll try to remedy it before #134 when I'm back from lunch.

@tarcieri
Copy link
Member

tarcieri commented Apr 6, 2015

I wouldn't be opposed to landing this despite the spec failures

@digitalextremist
Copy link
Member

Yeah, I'm just going to merge this now and fiddle with tests separately.

digitalextremist added a commit that referenced this pull request Apr 6, 2015
Avoid SSLSocket leaks by setting sync_close by default
@digitalextremist digitalextremist merged commit 235c6fb into celluloid:master Apr 6, 2015
@ixti
Copy link

ixti commented Apr 6, 2015

@digitalextremist transpec helps a lot to update specs...

@digitalextremist
Copy link
Member

That's very helpful @ixti, thank you!

@e2 is this what you've been doing? :)

@digitalextremist
Copy link
Member

[ haha, now that all the tests are current :) ]

@e2
Copy link

e2 commented Apr 7, 2015

@digitalextremist - yeah, life would be hard without transpec. There are a few tricks, though (for outdated projects):

  1. first, update to RSpec 2.99, which is highly compatible with other 2.x versions + run tests
  2. update the spec/spec_helper config (remove stuff mostly) so tests run
  3. transpec + commit (best to temporarily add to Gemfile - best to use with Bundler)
  4. update to RSpec 3.2
  5. transpec again (will be different)
  6. remove transpec and update spec_helper with new RSpec features

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants