函数调用的主要流程:
Main Thread
main // AutoPtr _cimServerProcess( new CIMServerProcess ()); class CIMServerProcess : public ServerProcess
ServerProcess::platform_run()
CIMServerProcess::cimserver_run()
CIMServer::CIMServer() //构造函数 调用 CIMServer::_init
CIMServer::addaccpetor() //创建 HTTPAcceptor 的实例: 初始化 outputqueue为 HTTPAuthenticatorDelegator的实例
CIMServer::bind() //调用 HTTPAccpetor实例的 bind()函数, 完成create,bind listen 功能。
//最后调用solicitSocketMessage() 把create()得到的监听套接字描述符和对应的 MessageQueue
//子类实例的queueId 初始化 MonitorEntry 的实例。
//HTTPAcceptor 有三种类型 LOCAL_CONNECTION, IPV4_CONNECTION, IPV6_CONNECTION
CIMServer::runForver //This is the primary server runloop. It loops until a shutdown received
Monitor::run(500000) //事件监视器, 也就是reactor, 使用select io多路复用器,监控各种类型的多个套接字,维护 数组元素为 //MonitorEntry 类型的array<>
{ //This class monitors system-level events and notifies its clients of these events
//by posting messages to their queues.
if (entries[indx].type == MonitorEntry::TYPE_CONNECTION)
dst->run(); //HTTPConnection::run(), Messagetype:SOCKET_MESSAGE处理从connectfd收到的消息, //Messagetype: HTTP_MESSAGE 则向connectfd发送消息
if (entries[indx]. type == MonitorEntry :: TYPE_ACCEPTOR)
q->enqueue(msg); //利用多态性: 父类动态绑定到HTTPAcceptor的 enqueue 函数,
//并且初始化HTTPConnection 实例,初始化HTTPConnection的outputqueue为
//HTTPAcceptor的HTTPAuthenticatorDelegator。enqueue函数 完成accept,
//并把得到的连接描述符(connectfd)与其初始化的HTTPConnection队列放入同一个 //MonitorEntry 中绑定在一起。
}
request的过程
HTTPConnection::run()
HTTPConnection::handleEnqueue()
HTTPConnection::_handleReadEvent/HTTPConnection::_handleWriteEvent
HTTPAuthenticatorDelegator::enqueue()
HTTPAuthenticatorDelegator::handleEnqueue
HTTPAuthenticatorDelegator::handleHTTPMessage
CIMOperationRequestDecoder::enqueue()
CIMOperationRequestDecoder::handleHTTPMessage()
CIMOperationRequestDecoder::handleMethodCall()
CIMOperationRequestAuthorizer::handleEnqueue() //鉴权用户, 使用RACF?
MessageQueueService::enqueue()
MessageQueue::enqueue() //CIMOperationRequestDispatcher 是实际被调用的派生类
CIMOperationRequestDispatcher::handleEnqueue //请求分配器
CIMOperationRequestDispatcher::handleEnqueue(Message* request)//根据 requesttype 选择对应的处理函数,这里一getclass 为例
CIMOperationRequestDispatcher::handleGetClassRequest
ProviderManagerService::handleEnqueue(void)
ProviderManagerService::handleEnqueue(Message * message)
ProviderManagerService:_handle_async_request //启动cimserver中的 Provider线程. Thread entry point为 handleCimOperation
Provider Thread:
ProviderManagerService::handleCimOperation()
ProviderManagerService::handleCimRequest(op, legacy);
ProviderManagerService::_processMessage() // Forward the request to the ProviderManager //response.reset(_processMessage(request)); 并决定使用basic 还是oop router
BasicProvidermanagerRouter()::processMessage()
CMPIProviderManager::processMessage()
CMPIProviderManager::handleXXXXXRequest()
CMPIProvider::getInstMI()
CMPIInstanceMI * mi = _miVector.createInstMI(&_broker, &eCtx, &rc);
//_miVector.createInstMI 在CMPIProviderModule::load() 中被赋值为
//CMPIInstanceMI* pn ## _Create_InstanceMI(), 该函数是provider的工厂函数。
##END
tips:
ProviderManagerService:_handle_async_request() : main code logic
while ((rtn =_thread_pool->allocate_and_awaken((void *)this ,ProviderManagerService::handleCimOperation))
!= PEGASUS_THREAD_OK)
monitor的重要函数:
solictiSocketMessage(): 把 socket和其相关的messageQueue消息处理队列的QueueId关联起来, 放入MonitorEntry中
阅读(626) | 评论(0) | 转发(0) |