Bug #18873
closed
Need to use thread safe random number generation (unless c++11 already provides this)
Added by David Zafman about 7 years ago.
Updated about 3 years ago.
Description
We are using rand() throughout the code which man says isn't thread safe. We should determine if rand() with c++11 is thread safe or not. If it isn't use some other variant like rand_r(), boost? or c++11 features.
David Zafman wrote:
We are using rand() throughout the code which man says isn't thread safe. We should determine if rand() with c++11 is thread safe or not. If it isn't use some other variant like rand_r(), boost? or c++11 features.
The rand() function is not thread-safe. rand() range is often significantly smaller than you want it to be. The C++ <random> library gives you much more powerful PRNGs.
- Category set to common
- Assignee set to Jos Collin
- Source set to Community (dev)
- Assignee changed from Jos Collin to Jesse Williamson
Just to make sure the signal isn't lost in the noise, the facility in this PR is an interface to the C++11 standard random number facility that will be used to provide fixes for this bug report, once approved:
https://github.com/ceph/ceph/pull/15341
- Status changed from New to Closed
Also available in: Atom
PDF