Skip to content

Commit ab600c4

Browse files
committed
SERVER-6018 The MSGID type doesn't need to be atomic
1 parent 5b3f117 commit ab600c4

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

src/mongo/util/net/message.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace mongo {
5353
}
5454
}
5555

56-
MSGID NextMsgId;
56+
AtomicWord<MSGID> NextMsgId;
5757

5858
/*struct MsgStart {
5959
MsgStart() {
@@ -63,8 +63,7 @@ namespace mongo {
6363
} msgstart;*/
6464

6565
MSGID nextMessageId() {
66-
MSGID msgid = NextMsgId++;
67-
return msgid;
66+
return NextMsgId.fetchAndAdd(1);
6867
}
6968

7069
bool doesOpGetAResponse( int op ) {

src/mongo/util/net/message.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131

3232
#include <vector>
3333

34-
#include "mongo/bson/util/atomic_int.h"
34+
#include "mongo/platform/atomic_word.h"
35+
#include "mongo/platform/cstdint.h"
3536
#include "mongo/util/goodies.h"
3637
#include "mongo/util/net/hostandport.h"
3738
#include "mongo/util/net/sock.h"
@@ -47,7 +48,7 @@ namespace mongo {
4748
class MessagingPort;
4849
class PiggyBackData;
4950

50-
typedef AtomicUInt MSGID;
51+
typedef uint32_t MSGID;
5152

5253
enum Operations {
5354
opReply = 1, /* reply. responseTo is set. */

src/mongo/util/net/message_port.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ namespace mongo {
3939
class MessagingPort;
4040
class PiggyBackData;
4141

42-
typedef AtomicUInt MSGID;
43-
4442
class AbstractMessagingPort : boost::noncopyable {
4543
public:
4644
AbstractMessagingPort() : tag(0), _connectionId(0) {}

0 commit comments

Comments
 (0)