Browse Source

Z991239-5298 #comment feat: VTIMLoader do not use FSM in DealwithOldEvent, because of its staus affact dealing events

chenliangyu 1 year ago
parent
commit
e8b9081a3f
2 changed files with 40 additions and 6 deletions
  1. 39 0
      Module/mod_vtmloader/mod_vtmloader.cpp
  2. 1 6
      Module/mod_vtmloader/mod_vtmloader.h

+ 39 - 0
Module/mod_vtmloader/mod_vtmloader.cpp

@@ -5,6 +5,7 @@
 #include "publicFunExport.h"
 //#pragma comment(lib, "libpublicFun.lib")
 #include "tokenDefine.h"
+#include <thread>
 #include <SpIni.h>
 
 void VtmLoaderServerSession::Handle_SetTerminalNo(SpReqAnsContext<VtmLoaderService_SetTerminalNo_Req, VtmLoaderService_SetTerminalNo_Ans>::Pointer ctx)
@@ -133,6 +134,44 @@ void CVtmLoaderEntity::EntityLostProc(CSimpleStringA entityName)
 
 	return Error_Succeed;
 }
+
+	void CVtmLoaderEntity::DealWithOldEvent(SpReqAnsContext<VtmLoaderService_DealWithOldEvent_Req, VtmLoaderService_DealWithOldEvent_Ans>::Pointer ctx)
+	{
+		/*
+		DealWithOldEvent_Event* pEvt = new DealWithOldEvent_Event();
+		pEvt->ctx = ctx;
+		m_FSM.PostEventFIFO(pEvt);
+		*/
+		static SpReqAnsContext<VtmLoaderService_DealWithOldEvent_Req, VtmLoaderService_DealWithOldEvent_Ans>::Pointer s_ctx;
+		s_ctx = ctx;
+
+
+
+		auto dealOldEventThread = [&] {
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("DealWithOldEvent called eventId, %d", s_ctx->Req.eventId);
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("DealWithOldEvent called reqStrRev1, %s", s_ctx->Req.reqStrRev1);
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("DealWithOldEvent called reqStrRev2, %s", s_ctx->Req.reqStrRev2);
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("DealWithOldEvent called reqIntRev1, %d", s_ctx->Req.reqIntRev1);
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("DealWithOldEvent called reqIntRev2, %d", s_ctx->Req.reqIntRev2);
+			ErrorCodeEnum eErr = ErrorCodeEnum::Error_Succeed;
+			switch (s_ctx->Req.eventId)
+			{
+			case EVENT_CONSOLE_REQ_SHUTDOWN_SHELL:
+				LogWarn(Severity_Low, Error_Unexpect, 0x50100215, CSimpleStringA::Format("%x, reason:%s", EVENT_CONSOLE_REQ_SHUTDOWN_SHELL, s_ctx->Req.reqStrRev1.GetData()));
+				GetFunction()->GetPrivilegeFunction()->Reboot(RebootTrigger_DeadForever	, RebootWayEnum::RebootWay_Framework);
+				break;
+			case LOG_EVT_IEBROWSER_RESET_SITE_RESTART:
+				GetFunction()->GetPrivilegeFunction()->Reboot(RebootTrigger_ManualLocal, RebootWayEnum::RebootWay_Framework);
+				break;
+			default:
+				break;
+			}
+			s_ctx->Answer(eErr);
+		};
+
+		std::thread(dealOldEventThread).detach();
+	}
+
 SP_BEGIN_ENTITY_MAP()
 	SP_ENTITY(CVtmLoaderEntity)
 SP_END_ENTITY_MAP()

+ 1 - 6
Module/mod_vtmloader/mod_vtmloader.h

@@ -61,12 +61,7 @@ public:
 		m_FSM.PostEventFIFO(pEvt);
 	}
 
-	void DealWithOldEvent(SpReqAnsContext<VtmLoaderService_DealWithOldEvent_Req, VtmLoaderService_DealWithOldEvent_Ans>::Pointer ctx)
-	{
-		DealWithOldEvent_Event* pEvt = new DealWithOldEvent_Event();
-		pEvt->ctx = ctx;
-		m_FSM.PostEventFIFO(pEvt);
-	}
+	void DealWithOldEvent(SpReqAnsContext<VtmLoaderService_DealWithOldEvent_Req, VtmLoaderService_DealWithOldEvent_Ans>::Pointer ctx);
 	
 	virtual void OnEntityStateHook(const char* pszEntityName, const char* pszTriggerEntity, EntityStateEnum eState, EntityStateEnum eLastState);
 	virtual void OnUserStateHook(const char* pszEntityName, DWORD dwState, DWORD dwLastState) { return; }