modify threads
This commit is contained in:
@@ -678,8 +678,9 @@ void cleanup_args(ThreadArgs* args) {
|
||||
}
|
||||
|
||||
void* cloudfrontthread(void* arg) {
|
||||
///////////////////////////////////////
|
||||
ThreadArgs* args = static_cast<ThreadArgs*>(arg);
|
||||
|
||||
//不再需要入参20251208
|
||||
/*ThreadArgs* args = static_cast<ThreadArgs*>(arg);
|
||||
int argc = args->argc;
|
||||
char **argv = args->argv;
|
||||
|
||||
@@ -697,7 +698,9 @@ void* cloudfrontthread(void* arg) {
|
||||
std::cerr << "[cloudfrontthread] Failed to parse index from argv[0]: " << argv[0] << "\n";
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
(void)arg;
|
||||
const int index = 0;
|
||||
|
||||
// 更新线程状态为运行中
|
||||
pthread_mutex_lock(&thread_info[index].lock);
|
||||
@@ -705,8 +708,7 @@ void* cloudfrontthread(void* arg) {
|
||||
thread_info[index].state = THREAD_RUNNING;
|
||||
pthread_mutex_unlock(&thread_info[index].lock);
|
||||
|
||||
///////////////////////////////////////
|
||||
// 解析命令行参数
|
||||
/*// 解析命令行参数
|
||||
if(!parse_param(argc,argv)){
|
||||
std::cerr << "process param error,exit" << std::endl;
|
||||
cleanup_args(args);
|
||||
@@ -714,7 +716,7 @@ void* cloudfrontthread(void* arg) {
|
||||
}
|
||||
|
||||
// 线程使用完后清理参数
|
||||
cleanup_args(args);
|
||||
cleanup_args(args);*/
|
||||
|
||||
//路径获取
|
||||
FRONT_PATH = get_parent_directory();
|
||||
@@ -787,6 +789,12 @@ void* cloudfrontthread(void* arg) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(60));//每分钟检测一次
|
||||
}
|
||||
|
||||
// 退出前标记为 STOPPED,方便监控线程判断并重启
|
||||
pthread_mutex_lock(&thread_info[index].lock);
|
||||
thread_info[index].state = THREAD_STOPPED;
|
||||
printf("cloudfrontthread %d stopped\n", index);
|
||||
pthread_mutex_unlock(&thread_info[index].lock);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user