diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2011-10-19 15:22:34 +0100 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2011-10-19 15:22:34 +0100 |
| commit | 502fc9e8c1009549780f98a06188ad36824c4252 (patch) | |
| tree | 6d410303ccab9057cbe99dc76d62d723170a7d1e /src | |
| parent | 5874d8c3ee0577366d23402e4674f194341451e9 (diff) | |
| download | rabbitmq-server-git-502fc9e8c1009549780f98a06188ad36824c4252.tar.gz | |
2) Produce guids a bit more efficiently.
(At the cost of limiting us to 2^64 messages published per channel.)
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_guid.erl | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/rabbit_guid.erl b/src/rabbit_guid.erl index cf3fea1a53..8cc80df42c 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) -> |
