-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,6 +180,7 @@ in the Erlang Reference Manual. | |
-type connection_type() :: normal | hidden. | ||
|
||
-include("net_address.hrl"). | ||
-include_lib("kernel/include/logger.hrl"). | ||
|
||
%% Relaxed typing to allow ets:select without Dialyzer complains. | ||
-record(connection, { | ||
|
@@ -2399,12 +2400,8 @@ split_node(Name) -> | |
%% | ||
-doc false. | ||
protocol_childspecs() -> | ||
case init:get_argument(proto_dist) of | ||
{ok, [Protos]} -> | ||
protocol_childspecs(Protos); | ||
_ -> | ||
protocol_childspecs(["inet_tcp"]) | ||
end. | ||
Protos = proto_dist_argument(), | ||
protocol_childspecs(Protos). | ||
|
||
protocol_childspecs([]) -> | ||
[]; | ||
|
@@ -2456,17 +2453,31 @@ hidden_argument() -> | |
false | ||
end. | ||
|
||
%%% | ||
%%% -proto_dist command line argument | ||
%%% | ||
|
||
proto_dist_argument() -> | ||
case init:get_argument(proto_dist) of | ||
{ok, [Protos | Rest]} -> | ||
case Rest of | ||
[] -> | ||
ok; | ||
_ -> | ||
?LOG_WARNING("Multiple -proto_dist given to erl, using the first, ~p", [Protos]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's fine. :-) |
||
end, | ||
Protos; | ||
_ -> | ||
["inet_tcp"] | ||
end. | ||
|
||
%% | ||
%% Start all protocols | ||
%% | ||
|
||
start_protos(Node, CleanHalt, Listen) -> | ||
case init:get_argument(proto_dist) of | ||
{ok, [Protos]} -> | ||
start_protos(Node, Protos, CleanHalt, Listen); | ||
_ -> | ||
start_protos(Node, ["inet_tcp"], CleanHalt, Listen) | ||
end. | ||
Protos = proto_dist_argument(), | ||
start_protos(Node, Protos, CleanHalt, Listen). | ||
|
||
start_protos(Node, Ps, CleanHalt, Listen) -> | ||
Listeners = case Listen of | ||
|
@@ -3011,4 +3022,3 @@ opts_node(Op, Node, Opts, From, #state{req_map = ReqMap0} = S0) -> | |
_ -> | ||
async_reply({reply, {error, noconnection}, S0}, From) | ||
end. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.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.
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.