Skip to content

Commit 895eb45

Browse files
Merge pull request #10478 from zzydxm/handshake_complete
Accept 4-arg handshake complete function in dist util OTP-20090
2 parents bfbbd0c + 7da680b commit 895eb45

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

erts/doc/guides/alt_dist.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,13 +553,16 @@ The following `#hs_data{}` record fields need to be set unless otherwise stated:
553553
following signature:
554554

555555
```erlang
556-
fun (DistCtrlr, Node, DHandle) -> void()
556+
fun (DistCtrlr, Node, DHandle) -> void() |
557+
fun (DistCtrlr, Node, DHandle, Context) -> void()
557558
```
558559

559560
where `DistCtrlr` is the identifier of the distribution controller, `Node` is
560-
the node name of the node connected at the other end, and `DHandle` is a
561-
distribution handle needed by a distribution controller process when calling
562-
the following BIFs:
561+
the node name of the node connected at the other end. `Context` is a map of
562+
`#{creation => Creation, flags => Flags}`, and `Creation` / `Flags` are the
563+
node incarnation identifier / [capability flags](erl_dist_protocol.md#dflags)
564+
of the node connected at the other end. `DHandle` is a distribution handle
565+
needed by a distribution controller process when calling the following BIFs:
563566

564567
- `erlang:dist_ctrl_get_data/1`
565568
- `erlang:dist_ctrl_get_data_notification/1`

lib/kernel/src/dist_util.erl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,8 @@ convert_flags(_Undefined) ->
497497
f_getopts :: function() | 'undefined'}).
498498

499499
connection(#hs_data{other_node = Node,
500+
other_creation = Creation,
501+
other_flags = Flags,
500502
socket = Socket,
501503
f_address = FAddress,
502504
f_setopts_pre_nodeup = FPreNodeup,
@@ -512,7 +514,11 @@ connection(#hs_data{other_node = Node,
512514
ok ->
513515
case HSData#hs_data.f_handshake_complete of
514516
undefined -> ok;
515-
HsComplete -> HsComplete(Socket, Node, DHandle)
517+
HsComplete when is_function(HsComplete, 3) ->
518+
HsComplete(Socket, Node, DHandle);
519+
HsComplete when is_function(HsComplete, 4) ->
520+
Context = #{creation => Creation, flags => Flags},
521+
HsComplete(Socket, Node, DHandle, Context)
516522
end,
517523
con_loop(#state{kernel = HSData#hs_data.kernel_pid,
518524
node = Node,

0 commit comments

Comments
 (0)