diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2011-11-15 13:12:51 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2011-11-15 13:12:51 +0000 |
commit | 9df24dfb54a62d430bc9ce077b102a9f9abc35d6 (patch) | |
tree | e1b7d99c22fcfaf83fda57efd712b6a597668316 /src/rabbit_guid.erl | |
parent | 2b9a7d2205d6f6de86df494a1b2e2209232d093b (diff) | |
download | rabbitmq-server-9df24dfb54a62d430bc9ce077b102a9f9abc35d6.tar.gz |
Use {node(), make_ref()} rather than self().
Diffstat (limited to 'src/rabbit_guid.erl')
-rw-r--r-- | src/rabbit_guid.erl | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/rabbit_guid.erl b/src/rabbit_guid.erl index cf3fea1a..da89b684 100644 --- a/src/rabbit_guid.erl +++ b/src/rabbit_guid.erl @@ -76,14 +76,16 @@ guid() -> %% now() to move ahead of the system time), and b) it is really %% slow since it takes a global lock and makes a system call. %% - %% A persisted serial number, in combination with self/0 (which - %% 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. + %% A persisted serial number, the node, and a unique reference + %% uniquely identifies a process in space and time. We combine + %% that with a process-local counter to give us a GUID. + %% + %% We used to use self/0 here instead of the node and unique + %% reference. But PIDs wrap. G = case get(guid) of - undefined -> {{gen_server:call(?SERVER, serial, infinity), self()}, - 0}; - {S, I} -> {S, I+1} + undefined -> Serial = gen_server:call(?SERVER, serial, infinity), + {{Serial, node(), make_ref()}, 0}; + {S, I} -> {S, I+1} end, put(guid, G), erlang:md5(term_to_binary(G)). |