51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
|
|
#include "Webserv.hpp"
|
|
|
|
void Webserv::_close_client(int fd)
|
|
{
|
|
std::vector<Client>::iterator it = _clients.begin();
|
|
while (it != _clients.end())
|
|
{
|
|
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()");
|
|
_clients.erase(it);
|
|
break;
|
|
}
|
|
++it;
|
|
}
|
|
}
|
|
|
|
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()");
|
|
_clients.pop_back();
|
|
}
|
|
}
|
|
|
|
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()");
|
|
_listen_sockets.pop_back();
|
|
}
|
|
}
|