diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-01-08 15:28:37 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-01-08 17:33:05 -0800 |
| commit | c5b5bd910507520f7974a156a1de9d187f23bc2f (patch) | |
| tree | 9766716c795d88fe902c7196696c1389d76717ba /src/platform/posix/posix_thread.c | |
| parent | 4b166dd8ae417b818a5ba214d8f2e648ac1d5be9 (diff) | |
| download | nng-c5b5bd910507520f7974a156a1de9d187f23bc2f.tar.gz nng-c5b5bd910507520f7974a156a1de9d187f23bc2f.tar.bz2 nng-c5b5bd910507520f7974a156a1de9d187f23bc2f.zip | |
New ISAAC pRNG. This replaces other local hacks for random data.
Platforms must seed the pRNGs by offering an nni_plat_seed_prng()
routine. Implementations for POSIX using various options (including
the /dev/urandom device) are supplied.
Diffstat (limited to 'src/platform/posix/posix_thread.c')
| -rw-r--r-- | src/platform/posix/posix_thread.c | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/src/platform/posix/posix_thread.c b/src/platform/posix/posix_thread.c index e4e5e74b..991a08db 100644 --- a/src/platform/posix/posix_thread.c +++ b/src/platform/posix/posix_thread.c @@ -24,7 +24,6 @@ static pthread_mutex_t nni_plat_lock = PTHREAD_MUTEX_INITIALIZER; static int nni_plat_inited = 0; static int nni_plat_forked = 0; -static int nni_plat_next = 0; pthread_condattr_t nni_cvattr; pthread_mutexattr_t nni_mxattr; @@ -34,18 +33,6 @@ pthread_mutexattr_t nni_mxattr; int nni_plat_devnull = -1; -uint32_t -nni_plat_nextid(void) -{ - uint32_t id; - - pthread_mutex_lock(&nni_plat_lock); - id = nni_plat_next++; - pthread_mutex_unlock(&nni_plat_lock); - return (id); -} - - int nni_plat_mtx_init(nni_plat_mtx *mtx) { @@ -270,25 +257,6 @@ nni_plat_init(int (*helper)(void)) return (NNG_ENOMEM); } - // Generate a starting ID (used for Pipe IDs) -#ifdef NNG_HAVE_ARC4RANDOM - nni_plat_next = arc4random(); -#else - while (nni_plat_next == 0) { - uint16_t xsub[3]; - nni_time now = nni_clock(); - pid_t pid = getpid(); - - xsub[0] = (uint16_t) now; - xsub[1] = (uint16_t) (now >> 16); - xsub[2] = (uint16_t) (now >> 24); - xsub[0] ^= (uint16_t) pid; - xsub[1] ^= (uint16_t) (pid >> 16); - xsub[2] ^= (uint16_t) (pid >> 24); - nni_plat_next = nrand48(xsub); - } -#endif - if (pthread_atfork(NULL, NULL, nni_atfork_child) != 0) { pthread_mutex_unlock(&nni_plat_lock); (void) close(nni_plat_devnull); |
