summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2011-10-19 15:22:34 +0100
committerSimon MacMullen <simon@rabbitmq.com>2011-10-19 15:22:34 +0100
commitb1bc394b1b48e2d6a8d088232f02d175c9e68ab5 (patch)
tree6d410303ccab9057cbe99dc76d62d723170a7d1e
parent2b8d7c22b2fbee766e9007065f409b76f0663314 (diff)
downloadrabbitmq-server-b1bc394b1b48e2d6a8d088232f02d175c9e68ab5.tar.gz
2) Produce guids a bit more efficiently.
(At the cost of limiting us to 2^64 messages published per channel.)
-rw-r--r--src/rabbit_guid.erl14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/rabbit_guid.erl b/src/rabbit_guid.erl
index cf3fea1a..8cc80df4 100644
--- a/src/rabbit_guid.erl
+++ b/src/rabbit_guid.erl
@@ -80,13 +80,13 @@ guid() ->
%% includes the node name) uniquely identifies a process in space
%% and time. We combine that with a process-local counter to give
%% us a GUID.
- G = case get(guid) of
- undefined -> {{gen_server:call(?SERVER, serial, infinity), self()},
- 0};
- {S, I} -> {S, I+1}
- end,
- put(guid, G),
- erlang:md5(term_to_binary(G)).
+ {S, I} = case get(guid) of
+ undefined -> S0 = gen_server:call(?SERVER, serial, infinity),
+ {erlang:md5(term_to_binary({S0, self()})), 0};
+ {S0, I0} -> {S0, I0 + 1}
+ end,
+ put(guid, {S, I}),
+ <<S/binary, I:64>>.
%% generate a readable string representation of a GUID.
string_guid(Prefix) ->