From 955f384e22893a791b426b4e59bd7cf1fea6bda9 Mon Sep 17 00:00:00 2001 From: jdh8d <jdh8d@git.zephyr-software.com> Date: Tue, 27 Oct 2015 18:21:17 +0000 Subject: [PATCH] update for RNG seeding to use pid() instead of time() due to parallel copies getting the same seed accidentally --- src/zipr.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/zipr.cpp b/src/zipr.cpp index bb84e91..3c4ad0d 100644 --- a/src/zipr.cpp +++ b/src/zipr.cpp @@ -156,7 +156,10 @@ ZiprOptionsNamespace_t *ZiprImpl_t::RegisterOptions(ZiprOptionsNamespace_t *glob m_callbacks.SetDescription("Set the path of the file " "which contains any required callbacks."); m_seed.SetDescription("Seed the random number generator with this value."); - m_seed.SetValue((int)time(NULL)); + + // our pid is a fine default value -- had issues with time(NULL) as two copies of zipr from + // were getting the same time(NULL) return value since we invoked them in parallel. + m_seed.SetValue((int)getpid()); zipr_namespace->AddOption(&m_output_filename); zipr_namespace->AddOption(&m_callbacks); -- GitLab