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

Remove uses of temporary RAII objects

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Done
    • None
    • 3.5.4
    • Concurrency
    • None
    • Fully Compatible
    • ALL
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: