Browse Source

!2 try create iom again when failed and send RTA Code

chenliangyu 1 year ago
parent
commit
fea779334e
3 changed files with 12 additions and 3 deletions
  1. 3 0
      Framework/Common/RVCEventCode.h
  2. 7 2
      Framework/spbase/SpModule.cpp
  3. 2 1
      Framework/spshell/app.cpp

+ 3 - 0
Framework/Common/RVCEventCode.h

@@ -24,4 +24,7 @@ inline CSimpleStringA DWORD2Hex(DWORD cur)
 #define RTAERR_SPSHELL_EXCEPTION			"RTA0012"	//框架crash
 
 
+#define RTAERR_SPHOST_IOM_FAILED			"RTA0021"	//iom create failed
+
+
 #endif

+ 7 - 2
Framework/spbase/SpModule.cpp

@@ -15,6 +15,7 @@
 #endif //RVC_OS_WIN
 
 #include <winpr/thread.h>
+#include <RVCEventCode.h>
 
 SpModule::SpModule( sp_mod_t *mod, sp_cfg_shell_module_t *cfg_mod ) 
 	: m_arrEntity(NULL)
@@ -97,8 +98,12 @@ ErrorCodeEnum SpModule::Init( const char *url )
 	//sp_dbg_debug("to create iom instance...");
 	rc = sp_iom_create(url, m_mod->cfg->idx, &m_iom);
 	if (rc != 0) {
-		DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("creat iom instance failed!");
-		return Error_Param;
+		Sleep(500);
+		if (0 != (rc = sp_iom_create(url, m_mod->cfg->idx, &m_iom)))
+		{
+			DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setResultCode(RTAERR_SPHOST_IOM_FAILED)("creat iom instance failed!");
+			return Error_Param;
+		}
 	}
 
 	rc = sp_log_client_create(NULL, m_iom, &m_anonymous_log);

+ 2 - 1
Framework/spshell/app.cpp

@@ -178,6 +178,7 @@ static int kickoff_startlist()
 
 #include "shm_mem.h"
 #include "sp_runTask.h"
+#include <RVCEventCode.h>
 
 int  RenameLightPacks(const char *pszAdPath)
 {
@@ -432,7 +433,7 @@ int app_init(const sp_cfg_start_args_t* args, std::function<void(const char* msg
 	/** and create bus endpt inner*/
 	rc = sp_iom_create(env->url, SP_SHELL_MOD_ID, &g_app.iom);
 	if (rc != 0) {
-		DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("create iom failed!");
+		DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setResultCode(RTAERR_SPHOST_IOM_FAILED)("create iom failed!");
 #if defined(_MSC_VER)
 		return std::make_pair(rc, "create iom failed!");
 #else