[SERVER-27897] Remove uses of temporary RAII objects Created: 02/Feb/17  Updated: 05/Apr/17  Resolved: 16/Feb/17

Status: Closed
Project: Core Server
Component/s: Concurrency
Affects Version/s: None
Fix Version/s: 3.5.4

Type: Bug Priority: Major - P3
Reporter: Geert Bosch Assignee: Geert Bosch
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-27920 Fix incorrect locking of Client context Closed
depends on SERVER-27935 Fix serialization of concurrent fsync... Closed
depends on SERVER-27936 fix improper release of locks in mast... Closed
is depended on by SERVER-27984 Add clang-tidy run in addition to lint Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Storage 2017-03-06
Participants:

 Description   

A common RAII idiom for locking is as follows:

{
    stdx::lock_guard<Client> lk(*txn->getClient());
    // Do stuff while holding the lock
}

However, as the name of the object (lk) isn't referenced, this is very easily mistyped as:

{
    stdx::lock_guard<Client> (*txn->getClient());
    // Do stuff while surprisingly NOT holding the lock!!!
}

So, check for any occurrences of temporaries with constructors and instead use named variables.



 Comments   
Comment by Githook User [ 16/Feb/17 ]

Author:

{u'username': u'GeertBosch', u'name': u'Geert Bosch', u'email': u'geert@mongodb.com'}

Message: SERVER-27897 Remove uses of temporary RAII objects
Branch: master
https://github.com/mongodb/mongo/commit/fcb4bd6ea4655015baba72bada66a45a4f43f6aa

Generated at Thu Feb 08 04:16:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.