You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kg...@apache.org on 2015/06/18 22:15:48 UTC
[43/50] [abbrv] qpid-proton git commit: PROTON-904: provide a better
seed to srand()
PROTON-904: provide a better seed to srand()
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/824dfefd
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/824dfefd
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/824dfefd
Branch: refs/heads/kgiusti-python3
Commit: 824dfefd53ad88f305816273f9896f91dddc5d08
Parents: e38957a
Author: Ken Giusti <kg...@apache.org>
Authored: Thu Jun 18 13:31:06 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Thu Jun 18 13:31:06 2015 -0400
----------------------------------------------------------------------
proton-c/src/messenger/messenger.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/824dfefd/proton-c/src/messenger/messenger.c
----------------------------------------------------------------------
diff --git a/proton-c/src/messenger/messenger.c b/proton-c/src/messenger/messenger.c
index ec4fb2c..9749bf5 100644
--- a/proton-c/src/messenger/messenger.c
+++ b/proton-c/src/messenger/messenger.c
@@ -503,7 +503,10 @@ static char *build_name(const char *name)
if (!seeded) {
int pid = pn_i_getpid();
- srand(pn_i_now() + pid);
+ int nowish = (int)pn_i_now();
+ // the lower bits of time are the most random, shift pid to push some
+ // randomness into the higher order bits
+ srand(nowish ^ (pid<<16));
seeded = true;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org