diff options
author | Dwight <dwight@10gen.com> | 2010-06-02 16:04:43 -0400 |
---|---|---|
committer | Dwight <dwight@10gen.com> | 2010-06-02 16:04:43 -0400 |
commit | 42759019925ee83dee727273f60613c380d1a154 (patch) | |
tree | 485afbe4a22397aacd743c4db5f79a5f9d5b2c29 /util | |
parent | e90228a360f63736c8e3ca9fca7d5d4d78dcb643 (diff) | |
parent | 8bfc290d809e8e0d1e091e5dd7a390b82291f413 (diff) | |
download | mongo-42759019925ee83dee727273f60613c380d1a154.tar.gz |
Merge branch 'master' of github.com:mongodb/mongo
Diffstat (limited to 'util')
-rw-r--r-- | util/message.h | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/util/message.h b/util/message.h index a2813b291a8..bd6bc3b533a 100644 --- a/util/message.h +++ b/util/message.h @@ -1,4 +1,4 @@ -// message.h +// Message.h /* Copyright 2009 10gen Inc. * @@ -218,6 +218,18 @@ namespace mongo { } bool empty() const { return !_buf && _data.empty(); } + + int size() const{ + int res = 0; + if ( _buf ){ + res = _buf->len; + } else { + for (MsgVec::const_iterator it = _data.begin(); it != _data.end(); ++it){ + res += it->second; + } + } + return res; + } // concat multiple buffers - noop if <2 buffers already, otherwise can be expensive copy // can get rid of this if we make response handling smarter @@ -322,7 +334,7 @@ namespace mongo { p.send( _data, context ); } } - + private: void _setData( MsgData *d, bool freeIt ) { _freeIt = freeIt; @@ -331,7 +343,8 @@ namespace mongo { // if just one buffer, keep it in _buf, otherwise keep a sequence of buffers in _data MsgData * _buf; // byte buffer(s) - the first must contain at least a full MsgData unless using _buf for storage instead - vector< pair< char*, int > > _data; + typedef vector< pair< char*, int > > MsgVec; + MsgVec _data; bool _freeIt; }; |