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 <kgiu...@apache.org> Authored: Thu Jun 18 13:31:06 2015 -0400 Committer: Ken Giusti <kgiu...@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-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org