Currently, read concern and write concern objects are frozen at the first time that _mongoc_read_concern_get_bson() and _mongoc_write_concern_get_bson() are called, respectively. Once frozen, the objects can no longer be modified via the public API (setter functions will fail). This effectively caches the generated BSON internally.
Because freezing converts a mutable struct into an immutable value, libmongoc needs to copy user-supplied structs before attempting to convert them to BSON (see: WRITE_CONCERN_DOC()); however, there are still outstanding cases with collection-level write functions where we do not make copies and may inadvertently freeze the user's struct (as noted in CDRIVER-2274).
Consider removing the frozen state on these objects and instead have setter functions simply invalidate any previously generated BSON. Such a change would also let us remove the WRITE_CONCERN_DOC() macro and resolve CDRIVER-2274.
- duplicates
-
CDRIVER-2274 _mongoc_write_command_init() may freeze const mongoc_write_concern_t
- Closed
- related to
-
CDRIVER-2318 _mongoc_read_concern_freeze() assert failure if level is not set
- Closed