Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-2284

Invalidate generated BSON instead of freezing read and write concerns

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.9.0
    • Affects Version/s: 1.7.0
    • Component/s: libmongoc
    • Labels:
      None

      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.

            Assignee:
            jmikola@mongodb.com Jeremy Mikola
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: