[CDRIVER-145] bson_oid_gen() is not thread-safe Created: 29/May/12 Updated: 03/May/17 Resolved: 09/Nov/13 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | None |
| Affects Version/s: | 0.5.2, 0.6 |
| Fix Version/s: | TBD |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Pawel | Assignee: | Gary Murakami |
| Resolution: | Done | Votes: | 0 |
| Labels: | bson | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
* |
||
| Description |
|
bson_oid_gen() is not thread-safe. |
| Comments |
| Comment by Christian Hergert [ 09/Nov/13 ] | |
|
This is fixed in libbson. You can use the default bson_context_t which uses a thread-safe atomic, or keep your own copy for other potential optimizations. | |
| Comment by Frank J. Lhota [ 19/Mar/13 ] | |
|
One more change should be made before closing out this issue: in bson_oid_gen(), we have the declaration
Even if we register a thread-safe fuzz function, multiple threads can end up using the same fuzz, because the fuzz value is stored in the static fuzz variable, shared by all the threads. This problem has a simple fix: don't declare fuzz as static. | |
| Comment by Gary Murakami [ 28/Jul/12 ] | |
|
Re: bson_oid_gen()
| |
| Comment by Gary Murakami [ 28/Jul/12 ] | |
|
Another concern: | |
| Comment by Pawel [ 09/Jun/12 ] | |
|
Apparently, this is already solved by having allowing external functions to generated both the incremented part of the OID and its fuzz. This issue can be closed. | |
| Comment by Pawel [ 29/May/12 ] | |
|
May be GCC atomics can be considered, at least as a #if |