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

OID generation in C++ driver should be threadsafe

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Trivial - P5
    • Resolution: Fixed
    • None
    • 1.1.4
    • Internal Client
    • None

    Description

      we should improve OID() generation to be threadsafe. we can probably use boost interlockedincrement for this instead of inc++

      when done be sure to add a comment in jsobj.h / struct OID that it is threadsafe now. also, same thing in the C driver?

      void OID::init()

      { static unsigned machine = (unsigned) security.getNonce(); static unsigned inc = (unsigned) security.getNonce(); unsigned t = (unsigned) time(0); char *T = (char *) &t; data[0] = T[3]; data[1] = T[2]; data[2] = T[1]; data[3] = T[0]; (unsigned&) data[4] = machine; ++inc; T = (char *) &inc; char * raw = (char*)&b; raw[0] = T[3]; raw[1] = T[2]; raw[2] = T[1]; raw[3] = T[0]; }

      Attachments

        Activity

          People

            mathias@mongodb.com Mathias Stearn
            dwight@mongodb.com Dwight Merriman
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: