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 | e6a60dc204f902e6aec3da20cd486fd27969b018 (patch) | |
| tree | e1b7d99c22fcfaf83fda57efd712b6a597668316 | |
| parent | d3dafe16fc23aed0483463644e8adaf106e68674 (diff) | |
| download | rabbitmq-server-git-e6a60dc204f902e6aec3da20cd486fd27969b018.tar.gz | |
Use {node(), make_ref()} rather than self().
| -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 cf3fea1a53..da89b684d8 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)). |
