summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Mazzoli <francesco@rabbitmq.com>2012-01-31 13:55:53 +0000
committerFrancesco Mazzoli <francesco@rabbitmq.com>2012-01-31 13:55:53 +0000
commit25c69871c29d9a2361000cde453e194a8bbf8a76 (patch)
tree4261b969b5f3e08cd44c57e5faee1bf5261aa17f
parent32eb814073e868a2abee938a66479926f50ca830 (diff)
downloadrabbitmq-server-25c69871c29d9a2361000cde453e194a8bbf8a76.tar.gz
Update comment for gen/0.
-rw-r--r--src/rabbit_basic.erl2
-rw-r--r--src/rabbit_guid.erl5
2 files changed, 4 insertions, 3 deletions
diff --git a/src/rabbit_basic.erl b/src/rabbit_basic.erl
index 85a18c71..55bbdf3a 100644
--- a/src/rabbit_basic.erl
+++ b/src/rabbit_basic.erl
@@ -139,7 +139,7 @@ message(XName, RoutingKey, #content{properties = Props} = DecodedContent) ->
{ok, #basic_message{
exchange_name = XName,
content = strip_header(DecodedContent, ?DELETED_HEADER),
- id = rabbit_guid:gen(),
+ id = rabbit_guid:gen_secure(),
is_persistent = is_message_persistent(DecodedContent),
routing_keys = [RoutingKey |
header_routes(Props#'P_basic'.headers)]}}
diff --git a/src/rabbit_guid.erl b/src/rabbit_guid.erl
index 4fe6eaee..5751d660 100644
--- a/src/rabbit_guid.erl
+++ b/src/rabbit_guid.erl
@@ -90,8 +90,9 @@ blocks_to_binary({B1, B2, B3, B4}) ->
%% generate a GUID. This function should be used when performance is a
%% priority and predictability is not an issue. Otherwise, use gen_secure/0.
gen() ->
- %% We hash a fresh GUID and then XOR it with a process-local counter
- %% to get a new GUID each time.
+ %% We hash a fresh GUID with md5, split it in 5 blocks, and each time we
+ %% need a new guid we hash the first block and the counter and xor the
+ %% result with the remaining blocks.
{BS, I} =
case get(guid) of
undefined ->