summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-02-26 14:11:29 +0000
committerSimon MacMullen <simon@rabbitmq.com>2014-02-26 14:11:29 +0000
commitdf5203289883c8044c44e2a5f181fef9f9fc496a (patch)
treef06c2122c929468c05ae876373bf15191010eb51
parent6969eaeb23818c5e76906416ffa890cf1db54731 (diff)
downloadrabbitmq-server-bug26039.tar.gz
Don't quote node atoms, it makes the resulting string harder to use in shell scripts.bug26039
-rw-r--r--src/rabbit_misc.erl10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index 848c4a87..ab1c6063 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -685,7 +685,7 @@ pid_to_string(Pid) when is_pid(Pid) ->
<<131,103,100,NodeLen:16,NodeBin:NodeLen/binary,Id:32,Ser:32,Cre:8>>
= term_to_binary(Pid),
Node = binary_to_term(<<131,100,NodeLen:16,NodeBin:NodeLen/binary>>),
- format("<~w.~B.~B.~B>", [Node, Cre, Id, Ser]).
+ format("<~s.~B.~B.~B>", [Node, Cre, Id, Ser]).
%% inverse of above
string_to_pid(Str) ->
@@ -695,13 +695,7 @@ string_to_pid(Str) ->
case re:run(Str, "^<(.*)\\.(\\d+)\\.(\\d+)\\.(\\d+)>\$",
[{capture,all_but_first,list}]) of
{match, [NodeStr, CreStr, IdStr, SerStr]} ->
- %% the NodeStr atom might be quoted, so we have to parse
- %% it rather than doing a simple list_to_atom
- NodeAtom = case erl_scan:string(NodeStr) of
- {ok, [{atom, _, X}], _} -> X;
- {error, _, _} -> throw(Err)
- end,
- <<131,NodeEnc/binary>> = term_to_binary(NodeAtom),
+ <<131,NodeEnc/binary>> = term_to_binary(list_to_atom(NodeStr)),
[Cre, Id, Ser] = lists:map(fun list_to_integer/1,
[CreStr, IdStr, SerStr]),
binary_to_term(<<131,103,NodeEnc/binary,Id:32,Ser:32,Cre:8>>);