void MessageQueueService::handle_AsyncIoctl(AsyncIoctl *req) { switch (req->ctl) { case AsyncIoctl::IO_CLOSE: { MessageQueueService *service = static_cast<MessageQueueService *>(req->op->_service_ptr); #ifdef MESSAGEQUEUESERVICE_DEBUG PEGASUS_STD(cout) << service->getQueueName() << " Received AsyncIoctl::IO_CLOSE " << PEGASUS_STD(endl); #endif // respond to this message. this is fire and forget, so we don't need to delete anything. // this takes care of two problems that were being found // << Thu Oct 9 10:52:48 2003 mdd >> _make_response(req, async_results::OK); // ensure we do not accept any further messages // ensure we don't recurse on IO_CLOSE if (_incoming_queue_shutdown.value() > 0) break; // set the closing flag service->_incoming_queue_shutdown = 1; // empty out the queue while (1) { AsyncOpNode *operation; try { operation = service->_incoming.remove_first(); } catch(IPCException &) { break; } if (operation) { operation->_service_ptr = service; service->_handle_incoming_operation(operation); } else break; } // message processing loop // shutdown the AsyncDQueue service->_incoming.shutdown_queue(); return; } default: _make_response(req, async_results::CIM_NAK); } }
void cimom::_handle_cimom_op(AsyncOpNode *op) { Message* msg = op->getRequest(); // We handle only one message at present. PEGASUS_ASSERT( msg->getType() == ASYNC_IOCLOSE); _global_this->_routed_queue_shutdown = 1; _make_response(msg, async_results::OK); // All services are shutdown, empty out the queue for(;;) { AsyncOpNode* operation = 0; try { operation = _global_this->_routed_ops.dequeue(); if (operation) { _global_this->cache_op(operation); } else { break; } } catch (...) { break; } } // shutdown the AsyncQueue _global_this->_routed_ops.close(); // exit the routing thread. _die++; }
void MessageQueueService::handle_AsyncLegacyOperationStart(AsyncLegacyOperationStart *req) { // remove the legacy message from the request and enqueue it to its destination Uint32 result = async_results::CIM_NAK; Message *legacy = req->_act; if (legacy != 0) { MessageQueue* queue = MessageQueue::lookup(req->_legacy_destination); if (queue != 0) { if (queue->isAsync() == true) { (static_cast<MessageQueueService *>(queue))->handleEnqueue(legacy); } else { // Enqueue the response: queue->enqueue(req->get_action()); } result = async_results::OK; } } _make_response(req, result); }
void MessageQueueService::_handle_async_request(AsyncRequest *req) { if (req != 0) { req->op->processing(); Uint32 type = req->getType(); if (type == async_messages::HEARTBEAT) handle_heartbeat_request(req); else if (type == async_messages::IOCTL) handle_AsyncIoctl(static_cast<AsyncIoctl *>(req)); else if (type == async_messages::CIMSERVICE_START) handle_CimServiceStart(static_cast<CimServiceStart *>(req)); else if (type == async_messages::CIMSERVICE_STOP) handle_CimServiceStop(static_cast<CimServiceStop *>(req)); else if (type == async_messages::CIMSERVICE_PAUSE) handle_CimServicePause(static_cast<CimServicePause *>(req)); else if (type == async_messages::CIMSERVICE_RESUME) handle_CimServiceResume(static_cast<CimServiceResume *>(req)); else if (type == async_messages::ASYNC_OP_START) handle_AsyncOperationStart(static_cast<AsyncOperationStart *>(req)); else { // we don't handle this request message _make_response(req, async_results::CIM_NAK); } } }
void MessageQueueService::handle_CimServiceResume(CimServiceResume *req) { // clear the paused bit and update _capabilities &= (~(module_capabilities::paused)); update_service(_capabilities, _mask); _make_response(req, async_results::OK); // now tell the meta dispatcher we are stopped }
void MessageQueueService::handle_CimServicePause(CimServicePause *req) { // set the paused bit and update _capabilities |= module_capabilities::paused; update_service(_capabilities, _mask); _make_response(req, async_results::CIM_PAUSED); // now tell the meta dispatcher we are stopped }
void MessageQueueService::handle_CimServiceStop(CimServiceStop *req) { #ifdef MESSAGEQUEUESERVICE_DEBUG PEGASUS_STD(cout) << getQueueName() << "received STOP" << PEGASUS_STD(endl); #endif // set the stopeed bit and update _capabilities |= module_capabilities::stopped; _make_response(req, async_results::CIM_STOPPED); // now tell the meta dispatcher we are stopped update_service(_capabilities, _mask); }
void MessageQueueService::handle_CimServiceStart(CimServiceStart *req) { #ifdef MESSAGEQUEUESERVICE_DEBUG PEGASUS_STD(cout) << getQueueName() << "received START" << PEGASUS_STD(endl); #endif // clear the stoped bit and update _capabilities &= (~(module_capabilities::stopped)); _make_response(req, async_results::OK); // now tell the meta dispatcher we are stopped update_service(_capabilities, _mask); }
void CIMExportRequestDispatcher::_handle_async_request(AsyncRequest *req) { PEG_METHOD_ENTER(TRC_EXP_REQUEST_DISP, "CIMExportRequestDispatcher::_handle_async_request"); PEGASUS_ASSERT(req != 0 && req->op != 0); if (req->getType() == ASYNC_CIMSERVICE_STOP) { handle_CimServiceStop(static_cast<CimServiceStop *>(req)); } else if (req->getType() == ASYNC_ASYNC_LEGACY_OP_START) { Message *legacy = (static_cast<AsyncLegacyOperationStart *>(req)->get_action()); if (legacy->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) { Message* legacy_response = _handleExportIndicationRequest( (CIMExportIndicationRequestMessage*) legacy); // constructor puts itself into a linked list, DO NOT remove the new new AsyncLegacyOperationResult(req->op, legacy_response); _complete_op_node(req->op); delete legacy; } else { PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1, "CIMExportRequestDispatcher::_handle_async_request got " "unexpected legacy message type '%s'", MessageTypeToString(legacy->getType()))); _make_response(req, async_results::CIM_NAK); delete legacy; } } else { Base::_handle_async_request(req); } PEG_METHOD_EXIT(); }
void IndicationHandlerService::_handle_async_request(AsyncRequest *req) { if ( req->getType() == async_messages::CIMSERVICE_STOP ) { req->op->processing(); handle_CimServiceStop(static_cast<CimServiceStop *>(req)); } else if ( req->getType() == async_messages::ASYNC_LEGACY_OP_START ) { req->op->processing(); AutoPtr<Message> legacy(static_cast<AsyncLegacyOperationStart *>(req)->get_action()); //PEP 101 if (legacy->getType() == CIM_HANDLE_INDICATION_REQUEST_MESSAGE) { AutoPtr<Message> legacy_response(_handleIndication( (CIMHandleIndicationRequestMessage*) legacy.get())); //PEP 101 legacy.release(); AutoPtr<AsyncLegacyOperationResult> async_result(new AsyncLegacyOperationResult( req->getKey(), req->getRouting(), req->op, legacy_response.get())); //PEP 101 legacy_response.release(); async_result.release(); _complete_op_node(req->op, ASYNC_OPSTATE_COMPLETE, 0, 0); } else { Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2, "IndicationHandlerService::_handle_async_request got " "unexpected legacy message type '%u'", legacy->getType()); _make_response(req, async_results::CIM_NAK); } } else { Base::_handle_async_request(req); } }
void IndicationHandlerService::_handle_async_request(AsyncRequest* req) { if (req->getType() == ASYNC_CIMSERVICE_STOP) { handle_CimServiceStop(static_cast<CimServiceStop *>(req)); } else if (req->getType() == ASYNC_ASYNC_LEGACY_OP_START) { AutoPtr<Message> legacy( static_cast<AsyncLegacyOperationStart *>(req)->get_action()); if (legacy->getType() == CIM_HANDLE_INDICATION_REQUEST_MESSAGE) { AutoPtr<Message> legacy_response(_handleIndication( (CIMHandleIndicationRequestMessage*) legacy.get())); legacy.release(); AutoPtr<AsyncLegacyOperationResult> async_result( new AsyncLegacyOperationResult( req->op, legacy_response.get())); legacy_response.release(); async_result.release(); _complete_op_node(req->op); } else { PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL2, "IndicationHandlerService::_handle_async_request got " "unexpected legacy message type '%u'", legacy->getType())); _make_response(req, async_results::CIM_NAK); } } else { Base::_handle_async_request(req); } }
ThreadReturnType PEGASUS_THREAD_CDECL cimom::_routing_proc(void *parm) { Thread* myself = reinterpret_cast<Thread *>(parm); cimom* dispatcher = reinterpret_cast<cimom *>(myself->get_parm()); AsyncOpNode *op = 0; try { while (dispatcher->_die.get() == 0) { op = dispatcher->_routed_ops.dequeue_wait(); if (op == 0) { break; } else { MessageQueue *dest_q = op->_op_dest; // See if we are the destination. if (dest_q == _global_this) { dispatcher->_handle_cimom_op(op); continue; } MessageQueueService *dest_svc = static_cast<MessageQueueService *>(dest_q); Boolean accepted = false; if (dispatcher->_monitorCIMService(dest_svc)) { accepted = dest_svc->accept_async(op); dispatcher->_releaseCIMService(dest_svc); } if (accepted == false) { // Send NAK to requesting service. try { _make_response( op->_request.get(), async_results::CIM_NAK); } catch(...) { // May be bad_alloc caused _make_response to fail, // delete op. PEG_TRACE_CSTRING( TRC_MESSAGEQUEUESERVICE,Tracer::LEVEL1, "cimom::_make_response failed"); _global_this->cache_op(op); } } } } } // Note: We should never get exception and we are not expecting it. catch(const Exception &e) { PEG_TRACE((TRC_MESSAGEQUEUESERVICE,Tracer::LEVEL1, "Exception caught in cimom::_routing_proc : %s", (const char*)e.getMessage().getCString())); PEGASUS_ASSERT(false); } catch(const exception &e) { PEG_TRACE((TRC_MESSAGEQUEUESERVICE,Tracer::LEVEL1, "Exception caught in cimom::_routing_proc : %s", e.what())); PEGASUS_ASSERT(false); } catch(...) { PEG_TRACE_CSTRING(TRC_MESSAGEQUEUESERVICE,Tracer::LEVEL1, "Unknown Exception caught in cimom::_routing_proc"); PEGASUS_ASSERT(false); } return 0; }
void MessageQueueService::handle_AsyncOperationStart(AsyncOperationStart *req) { _make_response(req, async_results::CIM_NAK); }