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

Respect -proto_dist flag when specified multiple times #8672

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

jonatanklosko
Copy link
Contributor

Currently specifying multiple instances of -proto_dist ignores the flag altogether.

$ erl -name foo@::1 -proto_dist inet6_tcp
Erlang/OTP 28 [DEVELOPMENT] [erts-15.0.1] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]

Eshell V15.0.1 (press Ctrl+G to abort, type help(). for help)
(foo@::1)1> sys:get_state(erl_epmd).
{state,#Port<0.4>,62687,foo,inet6}

$ erl -name foo@::1 -proto_dist inet6_tcp -proto_dist inet6_tcp
Erlang/OTP 28 [DEVELOPMENT] [erts-15.0.1] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]

Eshell V15.0.1 (press Ctrl+G to abort, type help(). for help)
(foo@::1)1> sys:get_state(erl_epmd).
{state,#Port<0.4>,62693,foo,inet}

Copy link
Contributor

github-actions bot commented Jul 15, 2024

CT Test Results

    2 files     70 suites   1h 2m 17s ⏱️
1 544 tests 1 302 ✅ 242 💤 0 ❌
1 715 runs  1 441 ✅ 274 💤 0 ❌

Results for commit 4de3cc9.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@jonatanklosko jonatanklosko changed the base branch from master to maint July 16, 2024 14:56
@jhogberg
Copy link
Contributor

Thanks for the PR! Can you log a warning when the option is specified multiple times (c.f. #2227)?

@jhogberg jhogberg self-assigned this Jul 17, 2024
@jhogberg jhogberg added team:VM Assigned to OTP team VM enhancement and removed team:VM Assigned to OTP team VM labels Jul 17, 2024

proto_dist_argument() ->
case init:get_argument(proto_dist) of
{ok, [Protos | Rest]} ->
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sidenote: similar functions above do not have that warning.

A follow up question: is there a reason we process proto_dist as a list, instead of getting the first item? In other words, is there a case where the user would pass -proto_dist [proto1, proto2]. The docs say -proto_dist Proto, indicating a single value is expected.

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed, not all functions have that warning, nor do many other places elsewhere in the codebase that uses init:get_argument/1 (most seem to either ignore the flag or grab the first argument, both of them silently). It's rather inconsistent unfortunately, but there's nothing wrong with fixing it as we go.

As for processing as a list the intent seems to be supporting multiple protocols at the same time, but as you noted we haven't documented that anywhere so it's not supported.

[] ->
ok;
_ ->
?LOG_WARNING("Multiple -proto_dist given to erl, using the first, ~p", [Protos])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: the warning shows up twice, since we read the value in two places.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's fine. :-)

@jhogberg jhogberg added the testing currently being tested, tag is used by OTP internal CI label Jul 18, 2024
@jhogberg
Copy link
Contributor

Hi again, the tests ran fine and I'm ready to merge this as soon as the commits are squashed :-)

@jonatanklosko
Copy link
Contributor Author

@jhogberg rebased and squashed!

@jhogberg jhogberg removed the testing currently being tested, tag is used by OTP internal CI label Aug 27, 2024
@jhogberg jhogberg merged commit 98e7aea into erlang:maint Aug 27, 2024
16 checks passed
@jhogberg
Copy link
Contributor

Merged, thanks again for the PR!

@jonatanklosko jonatanklosko deleted the jk-proto-dist-multi branch August 27, 2024 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants