summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-01-08 10:45:38 +0000
committerSimon MacMullen <simon@rabbitmq.com>2014-01-08 10:45:38 +0000
commite699cf6a65cd769db627782f704706585c399e93 (patch)
tree154d5aa54dcdb8e71e57aba865cc06cad0f378f9
parent581e8e0716e2f55b73369644260f1875eb599236 (diff)
parent5da3e2b8fceda6964c121ac48cd59e2be43f2d71 (diff)
downloadrabbitmq-server-e699cf6a65cd769db627782f704706585c399e93.tar.gz
Merge bug25937
-rw-r--r--src/rabbit_binary_generator.erl22
-rw-r--r--src/rabbit_nodes.erl11
2 files changed, 21 insertions, 12 deletions
diff --git a/src/rabbit_binary_generator.erl b/src/rabbit_binary_generator.erl
index 8eaac10d..83f68ed3 100644
--- a/src/rabbit_binary_generator.erl
+++ b/src/rabbit_binary_generator.erl
@@ -120,18 +120,18 @@ table_field_to_binary({FName, T, V}) ->
[short_string_to_binary(FName) | field_value_to_binary(T, V)].
field_value_to_binary(longstr, V) -> [$S | long_string_to_binary(V)];
-field_value_to_binary(signedint, V) -> [$I | <<V:32/signed>>];
+field_value_to_binary(signedint, V) -> [$I, <<V:32/signed>>];
field_value_to_binary(decimal, V) -> {Before, After} = V,
- [$D | [Before, <<After:32>>]];
-field_value_to_binary(timestamp, V) -> [$T | <<V:64>>];
+ [$D, Before, <<After:32>>];
+field_value_to_binary(timestamp, V) -> [$T, <<V:64>>];
field_value_to_binary(table, V) -> [$F | table_to_binary(V)];
field_value_to_binary(array, V) -> [$A | array_to_binary(V)];
-field_value_to_binary(byte, V) -> [$b | <<V:8/unsigned>>];
-field_value_to_binary(double, V) -> [$d | <<V:64/float>>];
-field_value_to_binary(float, V) -> [$f | <<V:32/float>>];
-field_value_to_binary(long, V) -> [$l | <<V:64/signed>>];
-field_value_to_binary(short, V) -> [$s | <<V:16/signed>>];
-field_value_to_binary(bool, V) -> [$t | [if V -> 1; true -> 0 end]];
+field_value_to_binary(byte, V) -> [$b, <<V:8/unsigned>>];
+field_value_to_binary(double, V) -> [$d, <<V:64/float>>];
+field_value_to_binary(float, V) -> [$f, <<V:32/float>>];
+field_value_to_binary(long, V) -> [$l, <<V:64/signed>>];
+field_value_to_binary(short, V) -> [$s, <<V:16/signed>>];
+field_value_to_binary(bool, V) -> [$t, if V -> 1; true -> 0 end];
field_value_to_binary(binary, V) -> [$x | long_string_to_binary(V)];
field_value_to_binary(void, _V) -> [$V].
@@ -154,13 +154,13 @@ generate_array_iolist(Array) ->
short_string_to_binary(String) ->
Len = string_length(String),
- if Len < 256 -> [<<Len:8>> | String];
+ if Len < 256 -> [<<Len:8>>, String];
true -> exit(content_properties_shortstr_overflow)
end.
long_string_to_binary(String) ->
Len = string_length(String),
- [<<Len:32>> | String].
+ [<<Len:32>>, String].
string_length(String) when is_binary(String) -> size(String);
string_length(String) -> length(String).
diff --git a/src/rabbit_nodes.erl b/src/rabbit_nodes.erl
index b54fdd2e..5a1613a7 100644
--- a/src/rabbit_nodes.erl
+++ b/src/rabbit_nodes.erl
@@ -17,7 +17,9 @@
-module(rabbit_nodes).
-export([names/1, diagnostics/1, make/1, parts/1, cookie_hash/0,
- is_running/2, is_process_running/2]).
+ is_running/2, is_process_running/2, fqdn_nodename/0]).
+
+-include_lib("kernel/include/inet.hrl").
-define(EPMD_TIMEOUT, 30000).
@@ -35,6 +37,7 @@
-spec(cookie_hash/0 :: () -> string()).
-spec(is_running/2 :: (node(), atom()) -> boolean()).
-spec(is_process_running/2 :: (node(), atom()) -> boolean()).
+-spec(fqdn_nodename/0 :: () -> binary()).
-endif.
@@ -107,3 +110,9 @@ is_process_running(Node, Process) ->
undefined -> false;
P when is_pid(P) -> true
end.
+
+fqdn_nodename() ->
+ {ID, _} = rabbit_nodes:parts(node()),
+ {ok, Host} = inet:gethostname(),
+ {ok, #hostent{h_name = FQDN}} = inet:gethostbyname(Host),
+ list_to_binary(atom_to_list(rabbit_nodes:make({ID, FQDN}))).