summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2011-11-15 13:12:51 +0000
committerSimon MacMullen <simon@rabbitmq.com>2011-11-15 13:12:51 +0000
commit9df24dfb54a62d430bc9ce077b102a9f9abc35d6 (patch)
treee1b7d99c22fcfaf83fda57efd712b6a597668316
parent2b9a7d2205d6f6de86df494a1b2e2209232d093b (diff)
downloadrabbitmq-server-9df24dfb54a62d430bc9ce077b102a9f9abc35d6.tar.gz
Use {node(), make_ref()} rather than self().
-rw-r--r--src/rabbit_guid.erl16
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)).