[CXX-1300] Prevent mongoc_init/mongoc_cleanup from running more than once Created: 06/Apr/17  Updated: 01/Jul/21  Resolved: 24/May/17

Status: Closed
Project: C++ Driver
Component/s: Implementation
Affects Version/s: None
Fix Version/s: 3.2.0-rc0

Type: Bug Priority: Major - P3
Reporter: David Golden Assignee: Samuel Rossi (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Minor Change

 Description   

mongocxx::instance prevents creation of an instance when a singleton instance exists, but it does not appear to prevent creating and destroying multiple instances serially, which would result in calling mongoc_init and mongoc_cleanup more than once.

We should prevent this from happening and only ever allow a single instance to be created whether as a singleton or as a scoped object.



 Comments   
Comment by David Golden [ 01/Jul/21 ]

Hi, Puya. It's been a very long time, but I think it was in libsasl.

Comment by Puya Daravi [ 01/Jul/21 ]

david.golden Do you know where in SASL this singleton is propagated from? I would like to file a bug ticket upstream to see if it is possible to remove the limitation so that mongoc, mongocxx and my library can avoid having to enforce singleton ad infinitum.

Comment by Githook User [ 24/May/17 ]

Author:

{u'username': u'saghm', u'name': u'Saghm Rossi', u'email': u'saghmrossi@gmail.com'}

Message: CXX-1300 Ensure that only one mongocxx::instance can ever be created
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/84894600054b978408422b4203bdd0e6a8df20f3

Comment by David Golden [ 24/May/17 ]

IIRC, the problem is way upstream. mongoc_cleanup only ever runs once because libraries it depends on like SASL don't allow cleanup and reinitialization. Thus, libmongoc explicitly doesn't allow this. This is documented in the C driver docs.

Generated at Wed Feb 07 22:02:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.