完善日志系统,修复读取配置文件时的内存泄漏,初步添加熔断机制与指数退避机制
This commit is contained in:
@ -235,7 +235,7 @@ int teml(Ctl *self,int fifo[2])
|
||||
char input[MAX_BUF] = {'\0'};
|
||||
ctx *command = (ctx*)malloc(sizeof(ctx));
|
||||
Cmd cmd_dir[10];
|
||||
init_interpreter(cmd_dir,command,fifo);//初始化解释器
|
||||
init_interpreter(cmd_dir,command,fifo,self->logmanager);//初始化解释器
|
||||
//创建线程用于定期清理日志
|
||||
pthread_create(&self->logwathcher,NULL,self->logmanager->clear_log,self->logmanager);
|
||||
command->statue = 0;
|
||||
@ -248,6 +248,9 @@ int teml(Ctl *self,int fifo[2])
|
||||
perror("sys error");
|
||||
//将用户输入入队
|
||||
infifo(self,input);
|
||||
logs *log = (logs*)malloc(sizeof(logs));
|
||||
memcpy(log->log,input,sizeof(input));
|
||||
self->logmanager->in_log(log,self->logmanager);
|
||||
memcpy(command->command,input,sizeof(input));
|
||||
interpret(SIG_MOD,command,cmd_dir);
|
||||
const char fexp[256] = {'\0'};
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define CTL
|
||||
|
||||
#include <pthread.h>
|
||||
#include "tools/toml/toml.h"
|
||||
#include "tools/log/log.h"
|
||||
#include "interpreter/interpreter.h"
|
||||
|
||||
@ -19,6 +20,7 @@ typedef struct Ctl
|
||||
pthread_t logwathcher;
|
||||
log_manager *logmanager;
|
||||
ctx *command;//解释器上下文
|
||||
toml_table_t *config;
|
||||
}Ctl;
|
||||
|
||||
Ctl *init_tem(log_manager *logmanager);
|
||||
|
||||
Reference in New Issue
Block a user