本文整理汇总了C++中MessageHandler::process方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageHandler::process方法的具体用法?C++ MessageHandler::process怎么用?C++ MessageHandler::process使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageHandler
的用法示例。
在下文中一共展示了MessageHandler::process方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleIncomingMsg
/**
* Handles incoming messages from a given socket.
*
* Terminating conditions:
* 1. Assertions while handling the request.
* 2. Socket is closed.
* 3. Server is shutting down (based on inShutdown)
*
* @param arg this method is in charge of cleaning up the arg object.
*
* @return NULL
*/
static void* handleIncomingMsg(void* arg) {
TicketHolderReleaser connTicketReleaser( &Listener::globalTicketHolder );
scoped_ptr<HandleIncomingMsgParam> himArg(static_cast<HandleIncomingMsgParam*>(arg));
MessagingPort* inPort = himArg->inPort;
MessageHandler* handler = himArg->handler;
{
string threadName = "conn";
if ( inPort->connectionId() > 0 )
threadName = str::stream() << threadName << inPort->connectionId();
setThreadName( threadName.c_str() );
}
verify( inPort );
inPort->psock->setLogLevel(1);
scoped_ptr<MessagingPort> p( inPort );
string otherSide;
Message m;
try {
LastError * le = new LastError();
lastError.reset( le ); // lastError now has ownership
otherSide = p->psock->remoteString();
#ifdef MONGO_SSL
std::string x509SubjectName = p->psock->doSSLHandshake();
inPort->setX509SubjectName(x509SubjectName);
#endif
handler->connected( p.get() );
while ( ! inShutdown() ) {
m.reset();
p->psock->clearCounters();
if ( ! p->recv(m) ) {
if( !cmdLine.quiet ){
int conns = Listener::globalTicketHolder.used()-1;
const char* word = (conns == 1 ? " connection" : " connections");
log() << "end connection " << otherSide << " (" << conns << word << " now open)" << endl;
}
p->shutdown();
break;
}
handler->process( m , p.get() , le );
networkCounter.hit( p->psock->getBytesIn() , p->psock->getBytesOut() );
}
}
catch ( AssertionException& e ) {
log() << "AssertionException handling request, closing client connection: " << e << endl;
p->shutdown();
}
catch ( SocketException& e ) {
log() << "SocketException handling request, closing client connection: " << e << endl;
p->shutdown();
}
catch ( const DBException& e ) { // must be right above std::exception to avoid catching subclasses
log() << "DBException handling request, closing client connection: " << e << endl;
p->shutdown();
}
catch ( std::exception &e ) {
error() << "Uncaught std::exception: " << e.what() << ", terminating" << endl;
dbexit( EXIT_UNCAUGHT );
}
catch ( ... ) {
error() << "Uncaught exception, terminating" << endl;
dbexit( EXIT_UNCAUGHT );
}
// Normal disconnect path.
#ifdef MONGO_SSL
SSLManagerInterface* manager = getSSLManager();
if (manager)
manager->cleanupThreadLocals();
#endif
handler->disconnected( p.get() );
return NULL;
}