Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Acceptors to get peer and sock names if not present in Connections #743

Merged
merged 3 commits into from
Nov 8, 2016

Conversation

lampad
Copy link
Contributor

@lampad lampad commented Nov 7, 2016

On Jruby, when starting a tcp server locally using the 0 port argument (to select a random port), I was later trying to discover what port it was on by calling: Socket.unpack_sockaddr_in( EM.get_sockname( signature ) ).first

Because the server doesn't get added to the Connections HashMap, I was getting an NPE. This PR appears to address it in my local tests, and it favors entries in Connections and falls back to the Acceptors.

I also added a couple things to make java builds friendlier, and a missing constant that was also causing me some pains.

Things appear to install and run fine, but when I try to run tests (using JRuby 9.1.2.0), I end up getting many errors about too many files being open. I could crank up my ulimit (it's already at 512), but I'm not sure how much further I need to go.

Copy link
Member

@sodabrew sodabrew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome! Thank you!

s.platform = 'java'
else
s.extensions = ["ext/extconf.rb", "ext/fastfilereader/extconf.rb"]
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't recall how conditionals in the gemspec interact with rubygems.org?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... A good question. I'm not sure. I wasn't aware that there were any interactions between specs and rubygems.org. I thought it was all evaluated at ruby runtime. A quick google doesn't seem to bring up anything obvious.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What prompted your change here? I'm not a regular JRuby user, but let me know what the problem was / improvement is for?

Copy link
Contributor Author

@lampad lampad Nov 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting the platform and adding the jar file will build a 'java' gem that will be preferentially searched for and installed if you're on a java platform when it's available on rubygems.

Segregating out the extensions will prevent jruby from trying to build those extensions (which it can't do) so that the gem can be installed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've built and uploaded the Java gem without this, are you sure it's necessary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tmm1! So @lampad Would you pull this commit out from the PR and then I'll merge the Acceptor changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had been using rake gem and rake package and they didn't seem to be java-specific (it was still trying to build c-extensions when I installed the local one), but I didn't try rake build. Also, entirely possible I was doing something dumb.

I'd be happy to pull that out. I found a few more things I'd like to contribute. Would you prefer those in a separate PR, or in this same one?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry rake gem is correct, but you would need to ensure you were using jruby+rake to invoke it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must be doing something else wrong because this is what I get with my change reverted: https://gist.github.com/lampad/ac5ac84ea5c5d313f1af755fedee33c7

In any case, I'll go ahead and revert it.

Copy link
Member

@sodabrew sodabrew Nov 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lampad Before I build the 1.2.1 gem, I'll be sure to revisit this to make sure I can build the JRuby gem, but please do remove that commit for now.

@lampad
Copy link
Contributor Author

lampad commented Nov 7, 2016

I've got a couple more changes coming to support TLS connections (a few more missing constants, and setting some tls opts.

@lampad
Copy link
Contributor Author

lampad commented Nov 8, 2016

The other TLS changes I mentioned will come in another pull request, as there's some work to be done on the java side to support it.

@sodabrew sodabrew merged commit 7781236 into eventmachine:master Nov 8, 2016
@sodabrew
Copy link
Member

sodabrew commented Nov 9, 2016

@lampad Speaking of Java TLS, take a look at #471 and see if some of that can be forward-ported to the current master branch?

@lampad
Copy link
Contributor Author

lampad commented Nov 9, 2016

@sodabrew Sure. Looks good at first glance. I'll dig a bit deeper when I get some free time.

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

Successfully merging this pull request may close these issues.

3 participants