From 17cf21bcf8a2e29d2cbcf0a313474d2a4ee44f5d Mon Sep 17 00:00:00 2001 From: Tadao Tanikawa Date: Fri, 20 Nov 2020 23:36:23 +0900 Subject: Re-organized sub-directory by category Since all the sub-directories were placed in the first level, created sub-directories, "hal", "module", and "service" for classification and relocated each component. Signed-off-by: Tadao Tanikawa Change-Id: Ifdf743ac0d1893bd8e445455cf0d2c199a011d5c --- .../src/processlauncher/ProcessLauncher_if.cpp | 126 +++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100755 service/system/system_manager/server/src/processlauncher/ProcessLauncher_if.cpp (limited to 'service/system/system_manager/server/src/processlauncher/ProcessLauncher_if.cpp') diff --git a/service/system/system_manager/server/src/processlauncher/ProcessLauncher_if.cpp b/service/system/system_manager/server/src/processlauncher/ProcessLauncher_if.cpp new file mode 100755 index 0000000..3d9b2e9 --- /dev/null +++ b/service/system/system_manager/server/src/processlauncher/ProcessLauncher_if.cpp @@ -0,0 +1,126 @@ +/* + * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/////////////////////////////////////////////////////////////////////////////// +/// \ingroup tag_SystemManager +/// \brief This file provides support for process launching and termination. +/// +/////////////////////////////////////////////////////////////////////////////// +#include + +#include "ProcessLauncher.h" +#include "ss_sm_process_launcher_protocol.h" +#include "ss_sm_systemmanagerlog.h" + +template EFrameworkunifiedStatus ProcessLauncherCallback(HANDLE hThread) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + + C * pObj = static_cast(FrameworkunifiedGetThreadSpecificData(hThread)); + + if (pObj) { // LCOV_EXCL_BR_LINE 5:pObj must not be NULL + l_eStatus = (pObj->*M)(hThread); + } + + return l_eStatus; +} + +EFrameworkunifiedStatus ProcessLauncherOnStart(HANDLE hThread) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + EFrameworkunifiedStatus l_eStatus; + CProcessLauncher * pObj = new (std::nothrow) CProcessLauncher(NULL); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length) + + if (pObj) { // LCOV_EXCL_BR_LINE 5:new error + // LCOV_EXCL_BR_START 200:l_eStatus always return eFrameworkunifiedStatusOK + if (eFrameworkunifiedStatusOK != (l_eStatus = pObj->PLOnCmdStart(hThread))) { + // LCOV_EXCL_BR_STOP + // LCOV_EXCL_START 200:l_eStatus always return eFrameworkunifiedStatusOK + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, + " Error: pObj->PLOnCmdStart(hThread) errored: %d/'%s'", + l_eStatus, GetStr(l_eStatus).c_str()); + // LCOV_EXCL_STOP + } else { + FrameworkunifiedSetThreadSpecificData(hThread, pObj); + + FrameworkunifiedProtocolCallbackHandler aParentHandlers[] = { { + ePLThrdCmd_LAUNCH_MODULE_REQST, ProcessLauncherCallback< + CProcessLauncher, + &CProcessLauncher::PLOnCmdLaunchModule> }, { + ePLThrdCmd_TERMINATE_MODULE_REQST, ProcessLauncherCallback< + CProcessLauncher, + &CProcessLauncher::PLOnCmdTerminateModule> }, { + ePLThrdCmd_RELAUNCH_MODULE_REQST, ProcessLauncherCallback< + CProcessLauncher, + &CProcessLauncher::PLOnCmdRelaunchModule> }, { + ePLThrdCmd_MODULE_STATUS_REQST, ProcessLauncherCallback< + CProcessLauncher, + &CProcessLauncher::PLOnCmdModuleStatus> }, { + ePLThrdCmd_THREAD_STATUS_REQST, ProcessLauncherCallback< + CProcessLauncher, + &CProcessLauncher::PLOnCmdHeartbeatStatusReq> } }; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length) + + // LCOV_EXCL_BR_START 4:NSFW error case + if (eFrameworkunifiedStatusOK + != (l_eStatus = FrameworkunifiedAttachParentCallbacksToDispatcher(hThread, aParentHandlers, + static_cast(_countof(aParentHandlers))))) { + // LCOV_EXCL_BR_STOP + // LCOV_EXCL_START 4:NSFW error case + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, + " Error: FrameworkunifiedAttachParentCallbacksToDispatcher() errored: %d/'%s'", + l_eStatus, GetStr(l_eStatus).c_str()); + // LCOV_EXCL_STOP + } else { + // Add other Attaches here!!! + } + } + } else { // LCOV_EXCL_BR_LINE 5::new operation failed + // LCOV_EXCL_START 5:new error + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: new CProcessLauncher( NULL ) returned NULL"); + l_eStatus = eFrameworkunifiedStatusNullPointer; + // LCOV_EXCL_STOP + } + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +// LCOV_EXCL_START 200:Thread which registered in init_process_launcher() is never stoppped. +EFrameworkunifiedStatus ProcessLauncherOnStop(HANDLE hThread) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + EFrameworkunifiedStatus l_eStatus; + CProcessLauncher * pObj = static_cast(FrameworkunifiedGetThreadSpecificData(hThread)); + + if (pObj) { + if (eFrameworkunifiedStatusOK != (l_eStatus = pObj->PLOnCmdStop(hThread))) { + LOG_ERROR("PLOnCmdStop()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length) + } + delete pObj; + pObj = NULL; + } + + FrameworkunifiedSetThreadSpecificData(hThread, NULL); + + if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedDetachServiceFromDispatcher(hThread, FrameworkunifiedGetAppName(hThread)))) { + LOG_ERROR("FrameworkunifiedDetachServiceFromDispatcher()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length) + } + + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} +// LCOV_EXCL_STOP + -- cgit 1.2.3-korg