BUG: "Bad file descriptor" in _close_all_clients()
This commit is contained in:
@@ -9,10 +9,9 @@ void Webserv::_close_client(int fd)
|
||||
if (*it == fd)
|
||||
{
|
||||
// _epoll_update(fd, 0, EPOLL_CTL_DEL); // normalement superflu, DEBUG
|
||||
std::cerr << "close fd " << fd << "\n";
|
||||
if (::close(fd) == -1)
|
||||
std::perror("err close()");
|
||||
else
|
||||
std::cerr << "close fd " << fd << "\n";
|
||||
_clients.erase(it);
|
||||
break;
|
||||
}
|
||||
@@ -22,13 +21,18 @@ void Webserv::_close_client(int fd)
|
||||
|
||||
void Webserv::_close_all_clients()
|
||||
{
|
||||
/*
|
||||
** BUG : (since last Hugo changes ? commit 482a389 ? or redirection problem ?)
|
||||
** sometimes "err close(): Bad file descriptor"
|
||||
** on fd>0 that should be valid (5, 6, ...)
|
||||
** I seems to trigger the bug when i request multiples ressources before timeout
|
||||
*/
|
||||
while (!_clients.empty())
|
||||
{
|
||||
// _epoll_update(_clients.back().fd, 0, EPOLL_CTL_DEL); // normalement superflu, DEBUG
|
||||
std::cerr << "close fd " << _clients.back().get_cl_fd() << "\n";
|
||||
if (::close(_clients.back().get_cl_fd()) == -1)
|
||||
std::perror("err close()");
|
||||
else
|
||||
std::cerr << "close fd " << _clients.back().get_cl_fd() << "\n";
|
||||
_clients.pop_back();
|
||||
}
|
||||
}
|
||||
@@ -38,10 +42,9 @@ void Webserv::_close_all_listen_sockets()
|
||||
while (!_listen_sockets.empty())
|
||||
{
|
||||
// _epoll_update(_listen_sockets.back().fd, 0, EPOLL_CTL_DEL); // normalement superflu, DEBUG
|
||||
std::cerr << "close fd " << _listen_sockets.back().fd << "\n";
|
||||
if (::close(_listen_sockets.back().fd) == -1)
|
||||
std::perror("err close()");
|
||||
else
|
||||
std::cerr << "close fd " << _listen_sockets.back().fd << "\n";
|
||||
_listen_sockets.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user