Skip to content

Commit 7da680b

Browse files
committed
Accept 4-arg handshake complete function in dist util
1 parent 44ed472 commit 7da680b

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
@@ -494,6 +494,8 @@ convert_flags(_Undefined) ->
494494
f_getopts :: function() | 'undefined'}).
495495

496496
connection(#hs_data{other_node = Node,
497+
other_creation = Creation,
498+
other_flags = Flags,
497499
socket = Socket,
498500
f_address = FAddress,
499501
f_setopts_pre_nodeup = FPreNodeup,
@@ -509,7 +511,11 @@ connection(#hs_data{other_node = Node,
509511
ok ->
510512
case HSData#hs_data.f_handshake_complete of
511513
undefined -> ok;
512-
HsComplete -> HsComplete(Socket, Node, DHandle)
514+
HsComplete when is_function(HsComplete, 3) ->
515+
HsComplete(Socket, Node, DHandle);
516+
HsComplete when is_function(HsComplete, 4) ->
517+
Context = #{creation => Creation, flags => Flags},
518+
HsComplete(Socket, Node, DHandle, Context)
513519
end,
514520
con_loop(#state{kernel = HSData#hs_data.kernel_pid,
515521
node = Node,

0 commit comments

Comments
 (0)