diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/mirrored_supervisor_tests.erl | 6 | ||||
| -rw-r--r-- | src/rabbit_control.erl | 24 | ||||
| -rw-r--r-- | src/rabbit_guid.erl | 9 |
3 files changed, 34 insertions, 5 deletions
diff --git a/src/mirrored_supervisor_tests.erl b/src/mirrored_supervisor_tests.erl index 0900f56fd8..6c91bc4fd5 100644 --- a/src/mirrored_supervisor_tests.erl +++ b/src/mirrored_supervisor_tests.erl @@ -158,7 +158,7 @@ test_no_migration_on_shutdown() -> try call(worker, ping), exit(worker_should_not_have_migrated) - catch exit:{timeout_waiting_for_server, _} -> + catch exit:{timeout_waiting_for_server, _, _} -> ok end end, [evil, good]). @@ -245,10 +245,10 @@ inc_group() -> get_group(Group) -> {Group, get(counter)}. -call(Id, Msg) -> call(Id, Msg, 100, 10). +call(Id, Msg) -> call(Id, Msg, 1000, 100). call(Id, Msg, 0, _Decr) -> - exit({timeout_waiting_for_server, {Id, Msg}}); + exit({timeout_waiting_for_server, {Id, Msg}, erlang:get_stacktrace()}); call(Id, Msg, MaxDelay, Decr) -> try diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl index fa8dd262e1..20486af52b 100644 --- a/src/rabbit_control.erl +++ b/src/rabbit_control.erl @@ -98,6 +98,9 @@ start() -> {error, Reason} -> print_error("~p", [Reason]), rabbit_misc:quit(2); + {error_string, Reason} -> + print_error("~s", [Reason]), + rabbit_misc:quit(2); {badrpc, {'EXIT', Reason}} -> print_error("~p", [Reason]), rabbit_misc:quit(2); @@ -368,7 +371,23 @@ action(report, Node, _Args, _Opts, Inform) -> [print_report(Node, Q) || Q <- ?GLOBAL_QUERIES], [print_report(Node, Q, [V]) || Q <- ?VHOST_QUERIES, V <- VHosts], io:format("End of server status report~n"), - ok. + ok; + +action(eval, Node, [Expr], _Opts, _Inform) -> + case erl_scan:string(Expr) of + {ok, Scanned, _} -> + case erl_parse:parse_exprs(Scanned) of + {ok, Parsed} -> + {value, Value, _} = unsafe_rpc( + Node, erl_eval, exprs, [Parsed, []]), + io:format("~p~n", [Value]), + ok; + {error, E} -> + {error_string, format_parse_error(E)} + end; + {error, E, _} -> + {error_string, format_parse_error(E)} + end. %%---------------------------------------------------------------------------- @@ -443,6 +462,9 @@ system(Cmd) -> escape_quotes(Cmd) -> lists:flatten(lists:map(fun ($') -> "'\\''"; (Ch) -> Ch end, Cmd)). +format_parse_error({_Line, Mod, Err}) -> + lists:flatten(Mod:format_error(Err)). + %%---------------------------------------------------------------------------- default_if_empty(List, Default) when is_list(List) -> diff --git a/src/rabbit_guid.erl b/src/rabbit_guid.erl index 523af7492d..2d0f5014f2 100644 --- a/src/rabbit_guid.erl +++ b/src/rabbit_guid.erl @@ -89,8 +89,15 @@ guid() -> erlang:md5(term_to_binary(G)). %% generate a readable string representation of a GUID. +%% +%% employs base64url encoding, which is safer in more contexts than +%% plain base64. string_guid(Prefix) -> - Prefix ++ "-" ++ base64:encode_to_string(guid()). + Prefix ++ "-" ++ lists:foldl(fun ($\+, Acc) -> [$\- | Acc]; + ($\/, Acc) -> [$\_ | Acc]; + ($\=, Acc) -> Acc; + (Chr, Acc) -> [Chr | Acc] + end, [], base64:encode_to_string(guid())). binstring_guid(Prefix) -> list_to_binary(string_guid(Prefix)). |
