diff options
author | Sverker Eriksson <[email protected]> | 2018-02-26 15:54:44 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2018-03-02 19:16:48 +0100 |
commit | 7917c31757994f4f2fd344d0529de8bb193adc85 (patch) | |
tree | edd74440ff9003ad281798d88e8eb0cd4eb58b40 /lib/kernel | |
parent | 337919abe6ed9a97e15d5f471ef8f79d44cb8363 (diff) | |
download | otp-7917c31757994f4f2fd344d0529de8bb193adc85.tar.gz otp-7917c31757994f4f2fd344d0529de8bb193adc85.tar.bz2 otp-7917c31757994f4f2fd344d0529de8bb193adc85.zip |
kernel: Simplify dist flags handshake merging
to a simple 'band' operation into ChosenFlags
and no need to remember old 'this_flags' and 'other_flags'.
Diffstat (limited to 'lib/kernel')
-rw-r--r-- | lib/kernel/src/dist_util.erl | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/lib/kernel/src/dist_util.erl b/lib/kernel/src/dist_util.erl index 638b91e153..5871e7e8ee 100644 --- a/lib/kernel/src/dist_util.erl +++ b/lib/kernel/src/dist_util.erl @@ -116,22 +116,8 @@ dflag2str(_) -> "UNKNOWN". -remove_flag(Flag, Flags) -> - case Flags band Flag of - 0 -> - Flags; - _ -> - Flags - Flag - end. - -adjust_flags(ThisFlags, OtherFlags, RejectFlags) -> - case (?DFLAG_PUBLISHED band ThisFlags) band OtherFlags of - 0 -> - {remove_flag(?DFLAG_PUBLISHED, ThisFlags), - remove_flag(?DFLAG_PUBLISHED, OtherFlags)}; - _ -> - {ThisFlags, OtherFlags band (bnot RejectFlags)} - end. +adjust_flags(ThisFlags, OtherFlags) -> + ThisFlags band OtherFlags. publish_flag(hidden, _) -> 0; @@ -177,11 +163,9 @@ handshake_other_started(#hs_data{request_type=ReqType, {PreOtherFlags,Node,Version} = recv_name(HSData0), EDF = erts_internal:get_dflags(), PreThisFlags = make_this_flags(ReqType, AddFlgs, RejFlgs, Node, EDF), - {ThisFlags, OtherFlags} = adjust_flags(PreThisFlags, - PreOtherFlags, - RejFlgs), - HSData = HSData0#hs_data{this_flags=ThisFlags, - other_flags=OtherFlags, + ChosenFlags = adjust_flags(PreThisFlags, PreOtherFlags), + HSData = HSData0#hs_data{this_flags=ChosenFlags, + other_flags=ChosenFlags, other_version=Version, other_node=Node, other_started=true, @@ -397,11 +381,9 @@ handshake_we_started(#hs_data{request_type=ReqType, send_name(HSData), recv_status(HSData), {PreOtherFlags,ChallengeA} = recv_challenge(HSData), - {ThisFlags,OtherFlags} = adjust_flags(PreThisFlags, - PreOtherFlags, - RejFlgs), - NewHSData = HSData#hs_data{this_flags = ThisFlags, - other_flags = OtherFlags, + ChosenFlags = adjust_flags(PreThisFlags, PreOtherFlags), + NewHSData = HSData#hs_data{this_flags = ChosenFlags, + other_flags = ChosenFlags, other_started = false}, check_dflags(NewHSData, EDF), MyChallenge = gen_challenge(), |