예제 #1
0
파일: dbmessage.cpp 프로젝트: Machyne/mongo
void OpQueryReplyBuilder::send(const transport::SessionHandle& session,
                               int queryResultFlags,
                               const Message& requestMsg,
                               int nReturned,
                               int startingFrom,
                               long long cursorId) {
    Message response;
    putInMessage(&response, queryResultFlags, nReturned, startingFrom, cursorId);

    response.header().setId(nextMessageId());
    response.header().setResponseToMsgId(requestMsg.header().getId());

    uassertStatusOK(session->sinkMessage(response).wait());
}
예제 #2
0
void ServiceEntryPointMock::run(transport::SessionHandle session) {
    Message inMessage;
    while (true) {
        {
            stdx::lock_guard<stdx::mutex> lk(_shutdownLock);
            if (_inShutdown)
                break;
        }

        // sourceMessage()
        if (!session->sourceMessage(&inMessage).wait().isOK()) {
            break;
        }

        auto resp = handleRequest(nullptr, inMessage, session->remote());

        // sinkMessage()
        if (!session->sinkMessage(resp.response).wait().isOK()) {
            break;
        }
    }
}