修改网络监听退出流程

This commit is contained in:
2025-09-29 16:50:51 +08:00
parent 8c52e4ba84
commit ef6acafd34
6 changed files with 48 additions and 9 deletions

View File

@ -206,21 +206,23 @@ int server_run(int port,int fifo_fd,netm *self)
ev.data.fd = fifo_fd;
epoll_ctl(epfd, EPOLL_CTL_ADD, fifo_fd, &ev);
char iss_buf[256];
int http_fd = init_network(port);
self->http_fd = init_network(port);
ev.data.fd = http_fd;
epoll_ctl(epfd, EPOLL_CTL_ADD, http_fd, &ev);
ev.data.fd = self->http_fd;
epoll_ctl(epfd, EPOLL_CTL_ADD, self->http_fd, &ev);
struct epoll_event events;
self->epoll_fd = epfd;
for(;;)
{
/*工作循环-----------------------------*/
int nf = epoll_wait(epfd,&events,1,-1);
if (nf == -1) {
perror("epoll_wait");
break;
}
if(events.data.fd ==http_fd)
if(events.data.fd ==self->http_fd)
{
int nt_fd = accept4(http_fd,NULL,NULL,SOCK_NONBLOCK | SOCK_CLOEXEC);
int nt_fd = accept4(self->http_fd,NULL,NULL,SOCK_NONBLOCK | SOCK_CLOEXEC);
if(nt_fd == -1)
continue;
sprintf(iss_buf,"s/%d/e",nt_fd);
@ -234,6 +236,7 @@ int server_run(int port,int fifo_fd,netm *self)
switch(command){
case 'q':
//退出逻辑
quit_server(self);
return 1;
break;
case 'u':
@ -243,6 +246,7 @@ int server_run(int port,int fifo_fd,netm *self)
}
}
}
/*工作循环----------------------------*/
}
}

View File

@ -31,6 +31,8 @@ typedef struct network_manager
log_manager *logmanager;
int last_alc;
int port;
int epoll_fd;
int http_fd;
}netm;
typedef struct rebot_message