diff options
author | Eliot Horowitz <eliot@10gen.com> | 2012-06-10 00:18:37 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2012-06-10 00:18:37 -0400 |
commit | 1c7dca59fbfd2b2f042e2745a1ee58f2c48760d8 (patch) | |
tree | 4e69d1fb400e156f70535d72f71eeaab704bd290 /src/mongo/util/net | |
parent | 4e1b5c81b5b61d09c3b1e81ad663b61bb1857243 (diff) | |
download | mongo-1c7dca59fbfd2b2f042e2745a1ee58f2c48760d8.tar.gz |
SERVER-6053 - make a const copier for Message, not ideal, but correct
Diffstat (limited to 'src/mongo/util/net')
-rw-r--r-- | src/mongo/util/net/message.cpp | 14 | ||||
-rw-r--r-- | src/mongo/util/net/message.h | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/mongo/util/net/message.cpp b/src/mongo/util/net/message.cpp index 8acaf601916..31188673c8a 100644 --- a/src/mongo/util/net/message.cpp +++ b/src/mongo/util/net/message.cpp @@ -42,6 +42,20 @@ namespace mongo { } } + + Message& Message::operator=(const Message& r) { + verify( empty() ); + verify( r._data.size() == 0 ); + verify( r._buf ); + + int x = r.size(); + char* buf = (char*)malloc(x); + verify(buf); + memcpy( buf , r._buf->_data , x ); + setData( reinterpret_cast<MsgData*>(buf) , true ); + return *this; + } + MSGID NextMsgId; /*struct MsgStart { diff --git a/src/mongo/util/net/message.h b/src/mongo/util/net/message.h index 17b685f14bc..27e868e1d1d 100644 --- a/src/mongo/util/net/message.h +++ b/src/mongo/util/net/message.h @@ -223,6 +223,8 @@ namespace mongo { return *this; } + Message& operator=(const Message& r); + void reset() { if ( _freeIt ) { if ( _buf ) { |