修改网络监听退出流程

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

@ -1,9 +1,40 @@
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/epoll.h>
#include "quit.h"
#include "tem/ctl.h"
int quit_server(netm *self)
{
if(self ==NULL)
return -1;
if(self->epoll_fd != -1)
{
epoll_ctl(self->epoll_fd,EPOLL_CTL_DEL,self->http_fd,NULL);
epoll_ctl(self->epoll_fd,EPOLL_CTL_DEL,self->fifo_fd[0],NULL);
self->epoll_fd = -1;
}
//关闭epoll监听
if(self->http_fd != -1)
{
close(self->http_fd);
self->http_fd =-1;
}
//关闭socket监听
if(self->fifo_fd[0] != -1)
{
close(self->fifo_fd[0]);
self->fifo_fd[0] = -1;
}
//关闭管道监听
}
void quit_all(int status,void *self_p)
{
alres *resouce =(alres*)self_p;
@ -13,6 +44,7 @@ void quit_all(int status,void *self_p)
logs *netlog = (logs*)malloc(sizeof(logs));
netlog->next = NULL;
memcpy(netlog->log,"shuting down networkserver",27);
quit_server(resouce->network);
resouce->loger->in_log(netlog,resouce->loger);
free(resouce->network);
//释放网络资源