mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-28 12:58:00 +03:00
fix: fix FARA segfault !!!
This commit is contained in:
@@ -145,16 +145,17 @@ int Server::delete_client(std::map<int, Client *> &client_map, int fd)
|
|||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int Server::delete_fd(std::map<int, t_tmp_fd *> &map, int fd)
|
int Server::delete_fd(std::map<int, t_tmp_fd *> &map, std::map<int, t_tmp_fd *>::iterator &it)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ret = epoll_ctl(_epoll_fd, EPOLL_CTL_DEL, fd, NULL);
|
ret = epoll_ctl(_epoll_fd, EPOLL_CTL_DEL, it->first, NULL);
|
||||||
delete map[fd];
|
// delete map[fd];
|
||||||
close(fd);
|
delete it->second;
|
||||||
map.erase(fd);
|
close(it->first);
|
||||||
|
map.erase(it++);
|
||||||
DBOUT << WARNING << getDebugTime() << OKCYAN
|
DBOUT << WARNING << getDebugTime() << OKCYAN
|
||||||
<< " deleting fd "
|
<< " deleting fd "
|
||||||
<< fd
|
<< it->first
|
||||||
<< ENDL;
|
<< ENDL;
|
||||||
|
|
||||||
return (ret);
|
return (ret);
|
||||||
@@ -295,7 +296,8 @@ void Server::run(void)
|
|||||||
if (client_map[fd]->done)
|
if (client_map[fd]->done)
|
||||||
{
|
{
|
||||||
delete_client(client_map, fd);
|
delete_client(client_map, fd);
|
||||||
delete_fd(free_socket, fd);
|
std::map<int, t_tmp_fd *>::iterator it = free_socket.find(fd);
|
||||||
|
delete_fd(free_socket, it);
|
||||||
}
|
}
|
||||||
else if (client_map[fd]->readyToSend())
|
else if (client_map[fd]->readyToSend())
|
||||||
{
|
{
|
||||||
@@ -322,10 +324,11 @@ void Server::run(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
free_it = free_socket.begin();
|
free_it = free_socket.begin();
|
||||||
for (; free_it != free_socket.end(); free_it++)
|
while (free_it != free_socket.end())
|
||||||
{
|
{
|
||||||
if (TimeToDie(free_it->second->last_modif, LIFE_TIME))
|
if (TimeToDie(free_it->second->last_modif, LIFE_TIME))
|
||||||
delete_fd(free_socket, free_it->first);
|
delete_fd(free_socket, free_it);
|
||||||
|
++free_it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DBOUT << RED << "end;" << ENDL;
|
DBOUT << RED << "end;" << ENDL;
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class Server
|
|||||||
struct timeval last_modif;
|
struct timeval last_modif;
|
||||||
}t_tmp_fd;
|
}t_tmp_fd;
|
||||||
bool TimeToDie(struct timeval &last_modif, int lifeTime);
|
bool TimeToDie(struct timeval &last_modif, int lifeTime);
|
||||||
int delete_fd(std::map<int, t_tmp_fd *> &map, int fd);
|
int delete_fd(std::map<int, t_tmp_fd *> &map, std::map<int, t_tmp_fd *>::iterator &it);
|
||||||
std::map<int, t_tmp_fd *> free_socket;
|
std::map<int, t_tmp_fd *> free_socket;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user