2011-06-26 18:23:57 -04:00
|
|
|
// message.cpp
|
2008-06-06 09:43:15 -04:00
|
|
|
|
2009-10-27 15:58:27 -04:00
|
|
|
/* Copyright 2009 10gen Inc.
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-06-27 09:13:59 -04:00
|
|
|
#include "pch.h"
|
2011-06-26 17:13:54 -04:00
|
|
|
|
2008-10-24 17:51:28 -04:00
|
|
|
#include <fcntl.h>
|
2009-04-06 16:21:56 -04:00
|
|
|
#include <errno.h>
|
2011-06-26 17:13:54 -04:00
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
|
|
#include "message.h"
|
2011-06-26 17:56:43 -04:00
|
|
|
#include "message_port.h"
|
2011-06-26 18:11:45 -04:00
|
|
|
#include "listen.h"
|
|
|
|
|
|
2011-06-26 17:13:54 -04:00
|
|
|
#include "../goodies.h"
|
|
|
|
|
#include "../../client/dbclient.h"
|
|
|
|
|
|
2009-01-14 17:09:51 -05:00
|
|
|
namespace mongo {
|
|
|
|
|
|
2011-06-26 17:56:43 -04:00
|
|
|
void Message::send( MessagingPort &p, const char *context ) {
|
|
|
|
|
if ( empty() ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ( _buf != 0 ) {
|
|
|
|
|
p.send( (char*)_buf, _buf->len, context );
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
p.send( _data, context );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-11 16:14:14 -04:00
|
|
|
MSGID NextMsgId;
|
|
|
|
|
|
2011-06-02 23:49:49 -04:00
|
|
|
/*struct MsgStart {
|
2009-09-11 16:14:14 -04:00
|
|
|
MsgStart() {
|
|
|
|
|
NextMsgId = (((unsigned) time(0)) << 16) ^ curTimeMillis();
|
|
|
|
|
assert(MsgDataHeaderSize == 16);
|
|
|
|
|
}
|
2011-06-02 23:49:49 -04:00
|
|
|
} msgstart;*/
|
2011-01-04 00:40:41 -05:00
|
|
|
|
|
|
|
|
MSGID nextMessageId() {
|
2010-01-25 19:32:00 -05:00
|
|
|
MSGID msgid = NextMsgId++;
|
2009-03-02 09:57:22 -05:00
|
|
|
return msgid;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-04 00:40:41 -05:00
|
|
|
bool doesOpGetAResponse( int op ) {
|
2009-03-17 17:24:38 -04:00
|
|
|
return op == dbQuery || op == dbGetMore;
|
|
|
|
|
}
|
2011-01-04 00:40:41 -05:00
|
|
|
|
2010-07-29 16:49:43 -04:00
|
|
|
|
2009-01-14 17:09:51 -05:00
|
|
|
} // namespace mongo
|