Преглед на файлове

Z991239-5349 #comment fea: sphost add startup param 'entity_id'

chenliangyu преди 1 година
родител
ревизия
5ff9ef3ed2
променени са 5 файла, в които са добавени 13 реда и са изтрити 12 реда
  1. 0 1
      Framework/spbase/SpBase.cpp
  2. 2 0
      Framework/spbase/sp_cfg.cpp
  3. 8 8
      Framework/spbase/sp_mod.c
  4. 1 1
      Framework/spbase/sp_mod.h
  5. 2 2
      Framework/sphost/sphost.c

+ 0 - 1
Framework/spbase/SpBase.cpp

@@ -118,7 +118,6 @@ static LONG WINAPI SuppressError(struct _EXCEPTION_POINTERS* ExceptionInfo)
 
 		BOOL rv = MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(), 
 			hDumpFile, mdt, (ExceptionInfo != 0) ? &mdei : 0, 0, 0 ); 
-
 		CloseHandle( hDumpFile );
 	}
 	DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__).setLogCode(ERR_ENTITY_EXCEPTION).setVtmCode(RTAERR_ENTITY_EXCEPTION)("exit entity exception, saveDmp, %s, detail:%d:%s"

+ 2 - 0
Framework/spbase/sp_cfg.cpp

@@ -1606,6 +1606,7 @@ static int shell_ini__load_entities_list(sp_dir_t* dir, sp_cfg_shell_ini_t* shel
 #endif //_MSC_VER
 						mod->mem_trace = memTraceArr.find(entity->name) == memTraceArr.end() ? 0 : memTraceArr[cur_it->first];
 						mod->idx = shell->arr_module->nelts;
+						//DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("mod idx, %s : %d", entity->name, mod->idx);
 						SHM_ARRAY_PUSH(shell->arr_module, sp_cfg_shell_module_t*) = mod;
 					}
 					else {
@@ -1617,6 +1618,7 @@ static int shell_ini__load_entities_list(sp_dir_t* dir, sp_cfg_shell_ini_t* shel
 				}
 				entity->mod = mod;
 				entity->idx = shell->arr_entity->nelts;
+				//DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("entity idx, %s : %d", entity->name, entity->idx);
 				SHM_ARRAY_PUSH(shell->arr_entity, sp_cfg_shell_entity_t*) = entity;
 				//DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("entity: %s, id: %d", entity->name, entity->idx);
 			}

+ 8 - 8
Framework/spbase/sp_mod.c

@@ -839,7 +839,7 @@ int assigntoJob(HANDLE process, int pid)
 }
 #endif //RVC_OS_WIN
 
-static int create_module_process(const char *mod_name, int epid, int range, int debugFileExist, tk_process_t* new_process, int runType)
+static int create_module_process(const char *mod_name, int epid, int range, int debugFileExist, tk_process_t* new_process, int runType, int entity_id)
 {
 	char app[MAX_PATH] = {'\0'};
 	int group = 0;
@@ -876,7 +876,7 @@ static int create_module_process(const char *mod_name, int epid, int range, int
 	else
 		sprintf(app, ".\\bin\\sphost_re.exe {%s} %d", mutexName, shellId);
 
-	sprintf_s(writeParam, sizeof(writeParam), "%s %d %d %s %d", mod_name, epid, range, mutexName, debugFileExist);
+	sprintf_s(writeParam, sizeof(writeParam), "%s %d %d %s %d %d", mod_name, epid, range, mutexName, debugFileExist, entity_id);
 
 	do {
 		sp_process_t* curProcess = ZALLOC_T(sp_process_t);
@@ -963,7 +963,7 @@ static int create_module_process(const char *mod_name, int epid, int range, int
 
 	tk_process_t* process = NULL;
 	tk_process_option_t option;
-	sprintf(app, "./bin/sphost %d %s %d %d", range, mod_name, epid, debugFileExist);
+	sprintf(app, "./bin/sphost %d %s %d %d %d", range, mod_name, epid, debugFileExist, entity_id);
 	option.exit_cb = NULL;
 	option.file = NULL;
 	option.flags = 0;
@@ -1771,7 +1771,7 @@ static void unlock_doing(sp_mod_mgr_t *mgr, sp_mod_t *mod)
 #endif //_WIN32
 }
 
-static int load_module(sp_mod_mgr_t *mgr, sp_mod_t *mod, int trigger_entity_id)
+static int load_module(sp_mod_mgr_t *mgr, sp_mod_t *mod, int trigger_entity_id, int entity_id)
 {
 	int rc = 0;
 	sp_env_t *env = sp_get_env();
@@ -1785,7 +1785,7 @@ static int load_module(sp_mod_mgr_t *mgr, sp_mod_t *mod, int trigger_entity_id)
 #endif //_WIN32
 	if (!mod->loaded) {
 		ResetEvent(mod->evt_app_exit);
-		if (0 != create_module_process(mod->cfg->name, mod->cfg->idx, env->shm_range, mod->cfg->debugFileExist, &mod->process, mod->cfg->runType)) {
+		if (0 != create_module_process(mod->cfg->name, mod->cfg->idx, env->shm_range, mod->cfg->debugFileExist, &mod->process, mod->cfg->runType, entity_id)) {
 			DbgWithLinkForC(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM, "sp_mod_mgr_load_module %s failed! create module process failed", mod->cfg->name);
 			rc = Error_Unexpect;
 		} else {
@@ -2462,7 +2462,7 @@ int sp_mod_mgr_start_entity(sp_mod_mgr_t *mgr, int entity_id, const char *cmdlin
 	ent = sp_mod_mgr_find_entity_by_idx(mgr, entity_id);
 	if (!ent)
 		return Error_NotExist;
-	return sp_mod_mgr_start_entity2(mgr, ent, cmdline, trigger_entity_id);
+	return sp_mod_mgr_start_entity2(mgr, ent, cmdline, trigger_entity_id, entity_id);
 }
 
 int sp_mod_mgr_stop_entity(sp_mod_mgr_t *mgr, int entity_id, int trigger_entity_id, int cause_code)
@@ -2555,7 +2555,7 @@ int sp_mod_mgr_terminate_all_entity(sp_mod_mgr_t* mgr, int trigger_entity_id)
 	return rc;
 }
 
-int sp_mod_mgr_start_entity2(sp_mod_mgr_t *mgr, sp_entity_t *ent, const char *cmdline, int trigger_entity_id)
+int sp_mod_mgr_start_entity2(sp_mod_mgr_t *mgr, sp_entity_t *ent, const char *cmdline, int trigger_entity_id, int entity_id)
 {
 	int rc = 0;
 	ULONGLONG curTickCount;
@@ -2576,7 +2576,7 @@ int sp_mod_mgr_start_entity2(sp_mod_mgr_t *mgr, sp_entity_t *ent, const char *cm
 			GetLocalTime(&ent->cfg->m_EntityStartTime);
 #endif //_MSC_VER
         if (!ent->mod->loaded)
-            rc = load_module(mgr, ent->mod, trigger_entity_id);	//start Entity process return init ok
+            rc = load_module(mgr, ent->mod, trigger_entity_id, entity_id);	//start Entity process return init ok
         if (isFirstStart)
 #if defined(_MSC_VER)
 			ent->cfg->m_EntityInitEndTime.longPart = sp_cfg_getShellFirstStartTime().longPart + clock() * 10000;

+ 1 - 1
Framework/spbase/sp_mod.h

@@ -202,7 +202,7 @@ SPBASE_API int sp_mod_mgr_terminate_all_entity(sp_mod_mgr_t* mgr, int trigger_en
 
 
 int sp_mod_mgr_terminate_entity2(sp_mod_mgr_t *mgr, sp_entity_t *entity, int trigger_entity_id);
-int sp_mod_mgr_start_entity2(sp_mod_mgr_t *mgr, sp_entity_t *entity, const char *cmdline, int trigger_entity_id);
+int sp_mod_mgr_start_entity2(sp_mod_mgr_t *mgr, sp_entity_t *entity, const char *cmdline, int trigger_entity_id, int entity_id);
 int sp_mod_mgr_stop_entity2(sp_mod_mgr_t *mgr, sp_entity_t *entity, int trigger_entity_id, int cause_code);
 int sp_mod_mgr_pause_entity2(sp_mod_mgr_t *mgr, sp_entity_t *entity, int trigger_entity_id);
 int sp_mod_mgr_continue_entity2(sp_mod_mgr_t *mgr, sp_entity_t *entity, int trigger_entity_id);

+ 2 - 2
Framework/sphost/sphost.c

@@ -337,7 +337,7 @@ int main(int argc, char *argv[])
 		if (-1 == (paramNum = paramSplit(readBuf, dstParam)))
 			continue;
 
-		if (!strcmp(dstParam[0], "start") && paramNum == 6)
+		if (!strcmp(dstParam[0], "start") && paramNum == 7)
 		{//start
 			
 			mod_runInfo *curModInfo = (mod_runInfo*)malloc(sizeof(mod_runInfo));
@@ -348,7 +348,7 @@ int main(int argc, char *argv[])
 			strcpy(curModInfo->modMutexName, dstParam[4]);
 			curModInfo->group = 0;
 			g_saveFile = atoi((dstParam[5]));
-			setCurEntityIdx(curModInfo->epid);
+			setCurEntityIdx(atoi(dstParam[6]));
 			createLogProducer(dstParam[1], dstParam[2]);
 			if (testDua1 > 100 || testDual2 > 100 || testDual3 > 100 || testDual4 > 100)
 				DbgWithLink_sphost("sphost initTest in %d-%d-%d-%d", testDua1, testDual2, testDual3, testDual4);