Skip to content

Commit

Permalink
Merge pull request #100 from lukebakken/lukebakken/recon-99
Browse files Browse the repository at this point in the history
Use NEW_PORT_EXT when Creation > 3
  • Loading branch information
ferd authored Jun 7, 2022
2 parents adaa2a5 + 5c9f1e2 commit f878e64
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/recon_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,24 @@ term_to_port("#Port<0."++Id) ->
term_to_port(N);
term_to_port(N) when is_integer(N) ->
%% We rebuild the term from the int received:
%% http://www.erlang.org/doc/apps/erts/erl_ext_dist.html#id86892
%% https://www.erlang.org/doc/apps/erts/erl_ext_dist.html#port_ext
%% https://www.erlang.org/doc/apps/erts/erl_ext_dist.html#new_port_ext
Name = iolist_to_binary(atom_to_list(node())),
NameLen = iolist_size(Name),
Vsn = binary:last(term_to_binary(self())),
{PortTag, VsnSize} = if
Vsn > 3 ->
{89, 4};
true ->
{102, 1}
end,
Bin = <<131, % term encoding value
102, % port tag
PortTag, % port tag, 102 or 89
100, % atom ext tag, used for node name
NameLen:2/unit:8,
Name:NameLen/binary,
N:4/unit:8, % actual counter value
Vsn:8>>, % version
Vsn:VsnSize/unit:8>>, % version
binary_to_term(Bin).

%% @doc Calls a given function every `Interval' milliseconds and supports
Expand Down

0 comments on commit f878e64

Please sign in to comment.