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

TCP backlog improvements #708

Merged
merged 6 commits into from
Mar 17, 2016
Merged

TCP backlog improvements #708

merged 6 commits into from
Mar 17, 2016

Conversation

michalwski
Copy link
Contributor

Proposed changes include:

  • increased tcp backlog for ejabberd_listeners
  • fix passing tcp opts from config file
  • test for default and passed backlog parameter

Also this PR is important to allow running parallel tests, introduced in #706, on MacOS X. Together with @pzel we discovered (mainly based on blogpost [1]) that the backlog queue implementation on MacOS X is less efficient than on linux. Too low backlog on MongooseIM side for port 5222 manifests by strange {error,econnreset}

[1]. http://veithen.github.io/2014/01/01/how-tcp-backlog-works-in-linux.html

default backlog value which is 5 is too low on MacOS X to successfully
run parallel tests, also it was discovered that passing sockert options
from config file stopped working
thanks @pzel for helping me with this
{packet, 0},
{active, false},
{reuseaddr, true},
{nodelay, true},
{send_timeout, ?TCP_SEND_TIMEOUT},
{keepalive, true},
{send_timeout_close, true}]),
{send_timeout_close, true} | SockOpts]),
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct me if I'm wrong, but won't this prevent our overrides from ever being picked up by gen_tcp:listen? The 'updated' values should be in front of the proplist.
Or, better yet, let's remove old values and add our overrides (using dict: functions will be the quickest).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, they have to be at the end, I looked into the gen_tcp, and inet code. There is a recursive function iterating on this opts and construing a record with opts.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see -- so that's very non-obvious, and someone may come along and change it later. Let's do it the right way so no "alternative" interpretation is possible.

do_override(inet6, Opts) ->
[inet6 | lists:delete(inet6, Opts)];
do_override(inet, Opts) ->
[inet | lists:delete(inet, Opts)];
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this explicit solution! One minor nitpick:

Isn't
[inet6 | lists:delete(inet6, Opts)]
the same thing as
Opts ?

Also, it's not technically possible to delete one of the inet|inet6 options now. Do we need those clauses? Maybe just erroring out with error({cannot_override_option, O, Opts}) would be more straightforward for the user?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it's not the same. What I wanted to achieve is to have only one inet6 or inet value in the list.

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 mean inet6 may not be in the Opts list but if it is, the I want only one such element in the list.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, got it now :)

pzel added a commit that referenced this pull request Mar 17, 2016
@pzel pzel merged commit 456c90b into rel-1.7 Mar 17, 2016
@michalwski michalwski deleted the fix-tcp-opts-passing-to-listener branch March 31, 2016 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants