修改网络监听退出流程
This commit is contained in:
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
/*工作循环----------------------------*/
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user