Compare commits
2 Commits
69ce2eed50
...
d11c1559ab
| Author | SHA1 | Date | |
|---|---|---|---|
| d11c1559ab | |||
| 3ada071d44 |
11
c/network/erroprocess/erroprocess.c
Normal file
11
c/network/erroprocess/erroprocess.c
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include "erroprocess.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
int give_upjobs(indiector *self)
|
||||||
|
{
|
||||||
|
if(self == NULL)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
20
c/network/erroprocess/erroprocess.h
Normal file
20
c/network/erroprocess/erroprocess.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#ifndef ERROPROCESS
|
||||||
|
#define EROPROCESS
|
||||||
|
typedef struct jobs
|
||||||
|
{
|
||||||
|
struct jobs* next;
|
||||||
|
int job;
|
||||||
|
}jobs;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct indiector
|
||||||
|
{
|
||||||
|
int status;//熔断标志位
|
||||||
|
int retreat_index;//退避指数
|
||||||
|
jobs *head_job;
|
||||||
|
jobs *rear_job;
|
||||||
|
}indiector;
|
||||||
|
|
||||||
|
int give_upjobs(indiector *self);
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -89,6 +89,7 @@ int init_network(int port)
|
|||||||
|
|
||||||
ssize_t read_req(int fd, void *buf)
|
ssize_t read_req(int fd, void *buf)
|
||||||
{
|
{
|
||||||
|
// TODO 修改读取任务函数
|
||||||
ssize_t n = read(fd, buf, MAX_MESSAGE_BUF);
|
ssize_t n = read(fd, buf, MAX_MESSAGE_BUF);
|
||||||
if (n == 0) /* 写端已关闭,管道永不会再有数据 */
|
if (n == 0) /* 写端已关闭,管道永不会再有数据 */
|
||||||
return -1;
|
return -1;
|
||||||
@ -97,6 +98,9 @@ ssize_t read_req(int fd, void *buf)
|
|||||||
|
|
||||||
int process_message(char *req,log_manager *logger)
|
int process_message(char *req,log_manager *logger)
|
||||||
{
|
{
|
||||||
|
//TODO 修改管道命令解析
|
||||||
|
if(req[0]!='s')
|
||||||
|
return 0;
|
||||||
const char *body = http_get_body(req);
|
const char *body = http_get_body(req);
|
||||||
rbt_msg message;
|
rbt_msg message;
|
||||||
rbt_parse_json(body,&message);
|
rbt_parse_json(body,&message);
|
||||||
|
|||||||
@ -272,6 +272,8 @@ Ctl *init_tem(log_manager *logmanager)
|
|||||||
tem->infifo = infifo;
|
tem->infifo = infifo;
|
||||||
tem->index = 0;
|
tem->index = 0;
|
||||||
tem->logmanager = logmanager;
|
tem->logmanager = logmanager;
|
||||||
|
char *his_buf[HISTORY_BUF] = {NULL};
|
||||||
|
memcpy(tem->history,his_buf,HISTORY_BUF);
|
||||||
for(int i =0;i<6;i++)
|
for(int i =0;i<6;i++)
|
||||||
{
|
{
|
||||||
tem->history[i] = NULL;
|
tem->history[i] = NULL;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
#include "interpreter/interpreter.h"
|
#include "interpreter/interpreter.h"
|
||||||
|
|
||||||
#define MAX_BUF 256
|
#define MAX_BUF 256
|
||||||
#define HISTORY_BUF 256
|
#define HISTORY_BUF 210
|
||||||
#define PROMPT "chatbot$$ "
|
#define PROMPT "chatbot$$ "
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user