From dab19d4fe2d4fe85a752194db01750e8995c8a57 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Mon, 1 Mar 2021 20:51:04 +0300 Subject: [PATCH] Merge pull request #2857 from rabbitmq/mk-direct-reply-to-erlang-22.x-compat Restore Erlang 22.3 compatibility for direct reply-to (cherry picked from commit 4465071820e143d8f380baca9dd2b4802da42840) --- deps/rabbit/src/pid_recomposition.erl | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/deps/rabbit/src/pid_recomposition.erl b/deps/rabbit/src/pid_recomposition.erl index b9a364476f4a..c98411b6bc0f 100644 --- a/deps/rabbit/src/pid_recomposition.erl +++ b/deps/rabbit/src/pid_recomposition.erl @@ -19,6 +19,7 @@ -define(TTB_PREFIX, 131). -define(NEW_PID_EXT, 88). +-define(PID_EXT, 103). -define(ATOM_UTF8_EXT, 118). -define(SMALL_ATOM_UTF8_EXT, 119). @@ -32,14 +33,26 @@ decompose(Pid) -> -spec from_binary(binary()) -> #{atom() => any()}. from_binary(Bin) -> - <> = Bin, + PidData = case Bin of + %% Erlang 23+ + <> -> Val0; + %% Erlang 22 + <> -> Val1 + end, {Node, Rest2} = case PidData of <> -> {Node0, Rest1}; <> -> {Node0, Rest1} end, - <> = Rest2, + {ID, Serial, Creation} = case Rest2 of + %% NEW_PID_EXT on Erlang 23+ + <> -> + {ID0, Serial0, Creation0}; + %% PID_EXT on Erlang 22 + <> -> + {ID1, Serial1, Creation1} + end, #{ node => binary_to_atom(Node, utf8), id => ID,