예제 #1
0
ObjectId::MachineAndPid ObjectId::genMachineAndPid()
{
  qint64 n = QScopedPointer<SecureRandom>(SecureRandom::create())->nextInt64();
  ObjectId::MachineAndPid x = ourMachine = reinterpret_cast<ObjectId::MachineAndPid&>(n);
  foldInPid(x);
  return x;
}
예제 #2
0
파일: oid.cpp 프로젝트: 328500920/mongo
 void OID::justForked() {
     MachineAndPid x = ourMachine;
     // we let the random # for machine go into all 5 bytes of MachineAndPid, and then
     // xor in the pid into _pid.  this reduces the probability of collisions.
     foldInPid(x);
     ourMachineAndPid = genMachineAndPid();
     verify( x != ourMachineAndPid );
     ourMachineAndPid = x;
 }
예제 #3
0
파일: oid.cpp 프로젝트: 328500920/mongo
    OID::MachineAndPid OID::genMachineAndPid() {
        BOOST_STATIC_ASSERT( sizeof(mongo::OID::MachineAndPid) == 5 );

        // we only call this once per process
        scoped_ptr<SecureRandom> sr( SecureRandom::create() );
        int64_t n = sr->nextInt64();
        OID::MachineAndPid x = ourMachine = reinterpret_cast<OID::MachineAndPid&>(n);
        foldInPid(x);
        return x;
    }
예제 #4
0
파일: oid.cpp 프로젝트: 89snake89/mongo
    OID::MachineAndPid OID::genMachineAndPid() {
        BOOST_STATIC_ASSERT( sizeof(mongo::OID::MachineAndPid) == 5 );

        // this is not called often, so the following is not expensive, and gives us some
        // testing that nonce generation is working right and that our OIDs are (perhaps) ok.
        {
            nonce64 a = Security::getNonceDuringInit();
            nonce64 b = Security::getNonceDuringInit();
            nonce64 c = Security::getNonceDuringInit();
            verify( !(a==b && b==c) );
        }

        unsigned long long n = Security::getNonceDuringInit();
        OID::MachineAndPid x = ourMachine = (OID::MachineAndPid&) n;
        foldInPid(x);
        return x;
    }
예제 #5
0
파일: oid.cpp 프로젝트: ALFIO/mongo
 static OID::MachineAndPid __gen() { 
     unsigned long long n = security.getNonce();
     OID::MachineAndPid x = ourMachine = (OID::MachineAndPid&) n;
     foldInPid(x);
     return x;
 }