diff options
author | Jose <jose@zeroc.com> | 2013-07-30 23:28:02 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2013-07-30 23:28:02 +0200 |
commit | 24e634c970ceec6a1ef5d8f7e5013d1e42a61fb6 (patch) | |
tree | 910419a01ecbc6940fb117a0fed80befe8883cb8 | |
parent | Fixed ICE-5364 - test/Ice/binding failure with IPv6 on Ubuntu (diff) | |
download | ice-24e634c970ceec6a1ef5d8f7e5013d1e42a61fb6.tar.bz2 ice-24e634c970ceec6a1ef5d8f7e5013d1e42a61fb6.tar.xz ice-24e634c970ceec6a1ef5d8f7e5013d1e42a61fb6.zip |
ICE-5330 - reset "/dev/urandom" state at fork.
-rw-r--r-- | cpp/src/IceUtil/Random.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cpp/src/IceUtil/Random.cpp b/cpp/src/IceUtil/Random.cpp index 5da54df01e7..8bd61f41270 100644 --- a/cpp/src/IceUtil/Random.cpp +++ b/cpp/src/IceUtil/Random.cpp @@ -47,6 +47,18 @@ Mutex* staticMutex = 0; HCRYPTPROV context = 0; #else int fd = -1; +// +// Callback to use with pthread_atfork to reset the "/dev/urandom" +// fd state. We don't need to close the fd here as that is done +// during static destruction. +// +void childAtFork() +{ + if(fd != -1) + { + fd = -1; + } +} #endif class Init @@ -56,6 +68,13 @@ public: Init() { staticMutex = new IceUtil::Mutex; +#ifndef _WIN32 + // + // Register a callback to reset the "/dev/urandom" fd + // state after fork. + // + pthread_atfork(0, 0, &childAtFork); +#endif } ~Init() |