[CDRIVER-1431] Document thread safety for mongoc_client_pool functions Created: 28/Jul/16  Updated: 28/Jan/17  Resolved: 27/Jan/17

Status: Closed
Project: C Driver
Component/s: docs
Affects Version/s: None
Fix Version/s: 1.6.0

Type: Improvement Priority: Trivial - P5
Reporter: Ian Boros Assignee: A. Jesse Jiryu Davis
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The docs for mongoc_client_pool_set_apm_callbacks say:

This function can only be called once on a pool, and must be called before the first mongoc_client_pool_pop.

There's no check for whether or not a client has been popped already in this function, so I think we should add that.

This might also be kind of a silly point, but I think this function should lock the client pool mutex, or (maybe) be described as "not thread safe" in the docs. In reality I'm sure nobody calls this function from multiple threads, but if someone did, the behavior would be weird.

mongoc_client_pool_set_error_api should probably lock the pool's mutex or be described as "not thread safe" in the docs as well. I'm guessing nobody actually calls this from multiple threads either, so I don't think it's a "real" bug, but it does look a bit strange.



 Comments   
Comment by Githook User [ 28/Jan/17 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-1431 document pool's thread safety
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/c70bc1678c5fb4952d8f2c3e76d92b47a20a7d54

Comment by A. Jesse Jiryu Davis [ 29/Jul/16 ]

Good idea. These functions - ones that must be called before the first pop - should take the mutex, check if any clients have been popped yet, and fail if so. They should be documented as "must be called before first client is popped", rather than being document as "not thread-safe".

Generated at Wed Feb 07 21:12:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.