Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
6641-erts-kernel-Fix-erlang-is_alive.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 6641-erts-kernel-Fix-erlang-is_alive.patch of Package erlang
From af22a8bafaab092669c2249081081916f0810b09 Mon Sep 17 00:00:00 2001 From: Rickard Green <rickard@erlang.org> Date: Wed, 25 May 2022 21:54:39 +0200 Subject: [PATCH 1/2] [erts, kernel] Fix erlang:is_alive() Ensure that the erlang:is_alive() BIF doesn't return 'true' until the configured distribution service is available. --- erts/emulator/test/distribution_SUITE.erl | 63 +++++++++++++++++++++- erts/preloaded/ebin/erlang.beam | Bin 131988 -> 132056 bytes erts/preloaded/ebin/erts_internal.beam | Bin 27924 -> 28608 bytes erts/preloaded/src/erlang.erl | 2 +- erts/preloaded/src/erts.app.src | 2 +- erts/preloaded/src/erts_internal.erl | 26 +++++++++ lib/kernel/src/kernel.app.src | 2 +- lib/kernel/src/net_kernel.erl | 28 +++++----- 8 files changed, 103 insertions(+), 20 deletions(-) diff --git a/erts/preloaded/src/erlang.erl b/erts/preloaded/src/erlang.erl index afd7012a10..5b0294e276 100644 --- a/erts/preloaded/src/erlang.erl +++ b/erts/preloaded/src/erlang.erl @@ -1279,7 +1279,7 @@ iolist_to_iovec(_IoListOrBinary) -> %% is_alive/0 -spec is_alive() -> boolean(). is_alive() -> - erlang:whereis(net_kernel) =/= undefined. + erlang:node() =/= nonode@nohost orelse erts_internal:dynamic_node_name(). %% is_builtin/3 -spec erlang:is_builtin(Module, Function, Arity) -> boolean() when diff --git a/erts/preloaded/src/erts_internal.erl b/erts/preloaded/src/erts_internal.erl index b666ef0b00..2aa8739388 100644 --- a/erts/preloaded/src/erts_internal.erl +++ b/erts/preloaded/src/erts_internal.erl @@ -116,6 +116,8 @@ -export([binary_to_integer/2, list_to_integer/2]). +-export([dynamic_node_name/0, dynamic_node_name/1]). + %% %% Await result of send to port %% @@ -978,3 +980,27 @@ binary_to_integer(_Bin, _Base) -> Base :: 2..36. list_to_integer(_List, _Base) -> erlang:nif_error(undefined). + +%% +%% Is dynamic node name enabled? +%% +-spec dynamic_node_name() -> boolean(). + +dynamic_node_name() -> + case persistent_term:get({?MODULE, dynamic_node_name}, false) of + false -> false; + _ -> true + end. + +%% +%% Save whether dynamic node name is enabled or not. +%% +-spec dynamic_node_name(boolean()) -> ok. + +dynamic_node_name(true) -> + persistent_term:put({?MODULE, dynamic_node_name}, true); +dynamic_node_name(false) -> + case dynamic_node_name() of + false -> ok; + _ -> _ = persistent_term:erase({?MODULE, dynamic_node_name}), ok + end. diff --git a/lib/kernel/src/net_kernel.erl b/lib/kernel/src/net_kernel.erl index 76279327b2..5db6ef2768 100644 --- a/lib/kernel/src/net_kernel.erl +++ b/lib/kernel/src/net_kernel.erl @@ -369,15 +369,15 @@ request(Req) -> end. retry_request_maybe(Req) -> - case persistent_term:get(net_kernel, undefined) of - dynamic_node_name -> + case erts_internal:dynamic_node_name() of + true -> %% net_kernel must be restarting due to lost connection %% toward the node that named us. %% We want reconnection attempts to succeed so we wait and retry. receive after 100 -> ok end, request(Req); - _ -> + false -> ignored end. @@ -531,6 +531,7 @@ init(#{name := Name, supervisor = Supervisor }}; Error -> + erts_internal:dynamic_node_name(false), {stop, Error} end. @@ -857,12 +858,12 @@ handle_call(get_state, From, State) -> net_sup -> static; _ -> dynamic end, - {NameType,Name} = case {persistent_term:get(net_kernel, undefined), node()} of - {undefined, Node} -> + {NameType,Name} = case {erts_internal:dynamic_node_name(), node()} of + {false, Node} -> {static, Node}; - {dynamic_node_name, nonode@nohost} -> + {true, nonode@nohost} -> {dynamic, undefined}; - {dynamic_node_name, Node} -> + {true, Node} -> {dynamic, Node} end, NameDomain = case get(longnames) of @@ -901,10 +902,7 @@ terminate(Reason, State) -> #state{supervisor = {restart, _}} -> ok; _ -> - case persistent_term:get(net_kernel, undefined) of - undefined -> ok; - _ -> persistent_term:erase(net_kernel) - end + erts_internal:dynamic_node_name(false) end, case Reason of @@ -1885,10 +1883,10 @@ epmd_module() -> %% dist_listen() -> whether the erlang distribution should listen for connections %% dist_listen() -> - case persistent_term:get(net_kernel, undefined) of - dynamic_node_name -> + case erts_internal:dynamic_node_name() of + true -> false; - _ -> + false -> case init:get_argument(dist_listen) of {ok,[[DoListen]]} -> list_to_atom(DoListen) =/= false; @@ -1928,7 +1926,7 @@ start_protos_no_listen(Node, [Proto | Ps], Ls, CleanHalt) -> {Name, "@"++_Host} = split_node(Node), Ok = case Name of "undefined" -> - persistent_term:put(net_kernel,dynamic_node_name), + erts_internal:dynamic_node_name(true), true; _ -> (set_node(Node, create_creation()) =:= ok) -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor