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

Remove uses of temporary RAII objects

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.5.4
    • Component/s: Concurrency
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Sprint:
      Storage 2017-03-06

      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.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: