Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.

Commit c1458ed

Browse files
committed
Support the NEW_PID_EXT format introduced in OTP-22
In OTP-22 the Creation field has been increased to be 32 bits. For now we only need to handle it when using term_to_binary and parsing the result manually.
1 parent 53d26da commit c1458ed

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/rabbit_misc.erl

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -706,15 +706,30 @@ pid_change_node(Pid, NewNode) ->
706706
node_to_fake_pid(Node) ->
707707
compose_pid(Node, 0, 0, 0).
708708

709+
-define(HAS_NEW_PID_EXT, false).
710+
-ifdef(OTP_RELEASE).
711+
-if(?OTP_RELEASE >= 22).
712+
-undef(HAS_NEW_PID_EXT).
713+
-define(HAS_NEW_PID_EXT, true).
714+
-endif.
715+
-endif.
716+
709717
decompose_pid(Pid) when is_pid(Pid) ->
710718
%% see http://erlang.org/doc/apps/erts/erl_ext_dist.html (8.10 and
711719
%% 8.7)
712720
Node = node(Pid),
713721
BinPid = term_to_binary(Pid),
714722
ByteSize = byte_size(BinPid),
715-
NodeByteSize = (ByteSize - 11),
716-
<<131, 103, _NodePrefix:NodeByteSize/binary, Id:32, Ser:32, Cre:8>> = BinPid,
717-
{Node, Cre, Id, Ser}.
723+
case ?HAS_NEW_PID_EXT of
724+
true ->
725+
NodeByteSize = (ByteSize - 14),
726+
<<131, 88, _NodePrefix:NodeByteSize/binary, Id:32, Ser:32, Cre:32>> = BinPid,
727+
{Node, Cre, Id, Ser};
728+
false ->
729+
NodeByteSize = (ByteSize - 11),
730+
<<131, 103, _NodePrefix:NodeByteSize/binary, Id:32, Ser:32, Cre:8>> = BinPid,
731+
{Node, Cre, Id, Ser}
732+
end.
718733

719734
compose_pid(Node, Cre, Id, Ser) ->
720735
<<131,NodeEnc/binary>> = term_to_binary(Node),

0 commit comments

Comments
 (0)