mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
Merge branch 'master' of git@github.com:mongodb/mongo
This commit is contained in:
commit
66f7357c3b
@ -1430,7 +1430,7 @@ namespace mongo {
|
||||
}
|
||||
|
||||
void OID::init() {
|
||||
static unsigned inc = (unsigned) security.getNonce();
|
||||
static WrappingInt inc = (unsigned) security.getNonce();
|
||||
unsigned t = (unsigned) time(0);
|
||||
char *T = (char *) &t;
|
||||
data[0] = T[3];
|
||||
@ -1440,9 +1440,8 @@ namespace mongo {
|
||||
|
||||
(unsigned&) data[4] = _machine;
|
||||
|
||||
// TODO: use compiler intrinsic atomic increment instead of inc++
|
||||
int old_inc = inc++;
|
||||
T = (char *) &old_inc;
|
||||
int new_inc = inc.atomicIncrement();
|
||||
T = (char *) &new_inc;
|
||||
char * raw = (char*)&b;
|
||||
raw[0] = T[3];
|
||||
raw[1] = T[2];
|
||||
|
@ -112,14 +112,16 @@ namespace mongo {
|
||||
x = 0;
|
||||
}
|
||||
WrappingInt(unsigned z) : x(z) { }
|
||||
unsigned x;
|
||||
volatile unsigned x;
|
||||
operator unsigned() const {
|
||||
return x;
|
||||
}
|
||||
WrappingInt& operator++() {
|
||||
x++;
|
||||
return *this;
|
||||
|
||||
// TODO: make atomic
|
||||
WrappingInt atomicIncrement(){
|
||||
return x++;
|
||||
}
|
||||
|
||||
static int diff(unsigned a, unsigned b) {
|
||||
return a-b;
|
||||
}
|
||||
|
@ -429,8 +429,7 @@ again:
|
||||
} msgstart;
|
||||
|
||||
MSGID nextMessageId(){
|
||||
MSGID msgid = NextMsgId;
|
||||
++NextMsgId;
|
||||
MSGID msgid = NextMsgId.atomicIncrement();
|
||||
|
||||
if ( usingClientIds ){
|
||||
msgid = msgid & 0xFFFF;
|
||||
|
Loading…
Reference in New Issue
Block a user