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

OID generation in C++ driver should be threadsafe

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Trivial - P5 Trivial - P5
    • 1.1.4
    • Affects Version/s: None
    • Component/s: Internal Client
    • None

      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]; }

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

              Created:
              Updated:
              Resolved: