//-------------------------------------------------------------------------------------------------- static void PrepareFullShutdown ( void ) { if (AsyncApiCmdRef != NULL) { if (State == STATE_STOPPING) { // Respond to the requesting process to tell it that the Legato framework has stopped. le_sup_ctrl_StopLegatoRespond(AsyncApiCmdRef, LE_OK); } else if (State == STATE_RESTARTING || State == STATE_RESTARTING_MANUAL) { // Respond to the requesting process to tell it that the Legato framework has stopped. le_sup_ctrl_RestartLegatoRespond(AsyncApiCmdRef, LE_OK); } else { LE_CRIT("Unexpected state %d.", State); } } // Close services that we've advertised before the Service Directory dies. le_msg_HideService(le_sup_ctrl_GetServiceRef()); le_msg_HideService(le_sup_wdog_GetServiceRef()); le_msg_HideService(le_appInfo_GetServiceRef()); le_msg_HideService(le_appProc_GetServiceRef()); }
//-------------------------------------------------------------------------------------------------- void le_msg_DeleteService ( le_msg_ServiceRef_t serviceRef ///< [in] Reference to the service. ) //-------------------------------------------------------------------------------------------------- { LE_FATAL_IF(serviceRef->serverThread != le_thread_GetCurrent(), "Attempted to delete service (%s:%s) not owned by thread.", serviceRef->id.name, le_msg_GetProtocolIdStr(serviceRef->id.protocolRef)); // If the service is still advertised, hide it. le_msg_HideService(serviceRef); // Close any remaining open sessions. CloseAllSessions(serviceRef); // NOTE: Lock the mutex here to prevent a race between this thread dropping ownership // of the service and another thread trying to offer the same service. This is very // unlikely to ever happen, but just in case, make sure it fails with a sensible // ("duplicate") log message, instead of just quietly messing up the hashmap or something. LOCK // Clear out the server thread reference. serviceRef->serverThread = NULL; // Release the server's hold on the object. le_mem_Release(serviceRef); UNLOCK }