Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-27897

Remove uses of temporary RAII objects

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.4
    • Affects Version/s: None
    • Component/s: Concurrency
    • None
    • Fully Compatible
    • ALL
    • Storage 2017-03-06

      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.

            Assignee:
            geert.bosch@mongodb.com Geert Bosch
            Reporter:
            geert.bosch@mongodb.com Geert Bosch
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: