mirror of
https://github.com/KeyZox71/webserv.git
synced 2025-06-25 09:33:36 +02:00
「🔨」 fix: fixed throw with client in main loop
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/17 11:12:41 by mmoussou #+# #+# */
|
/* Created: 2025/04/17 11:12:41 by mmoussou #+# #+# */
|
||||||
/* Updated: 2025/05/09 11:48:59 by adjoly ### ########.fr */
|
/* Updated: 2025/05/22 17:36:36 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ void Client::parse(void) {
|
|||||||
std::string host = _request->getHeader("Host");
|
std::string host = _request->getHeader("Host");
|
||||||
bool ret = _conf->isServerName(host.substr(0, host.find(':')));
|
bool ret = _conf->isServerName(host.substr(0, host.find(':')));
|
||||||
if (ret == false) {
|
if (ret == false) {
|
||||||
throw std::runtime_error("serverName nor correcponding");
|
throw std::runtime_error("serverName not correcponding");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/11 16:11:40 by adjoly #+# #+# */
|
/* Created: 2025/04/11 16:11:40 by adjoly #+# #+# */
|
||||||
/* Updated: 2025/05/19 15:11:00 by adjoly ### ########.fr */
|
/* Updated: 2025/05/22 17:36:13 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -176,7 +176,23 @@ void Server::_run(void) {
|
|||||||
_log->error("client does not exist");
|
_log->error("client does not exist");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
client->parse();
|
try {
|
||||||
|
client->parse();
|
||||||
|
} catch (std::exception &e) {
|
||||||
|
_log->error(e.what());
|
||||||
|
_client_data.erase(std::find(_client_data.begin(),
|
||||||
|
_client_data.end(), client));
|
||||||
|
delete client;
|
||||||
|
for (auto it = range(_client_fds)) {
|
||||||
|
if (_client_fds[i].fd == (*it).fd) {
|
||||||
|
_log->debug("client fds erased");
|
||||||
|
close(it.base()->fd);
|
||||||
|
_client_fds.erase(it);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i--;
|
||||||
|
}
|
||||||
} else if (_client_fds[i].revents & POLLOUT) {
|
} else if (_client_fds[i].revents & POLLOUT) {
|
||||||
std::stringstream str;
|
std::stringstream str;
|
||||||
str << _client_fds[i].fd;
|
str << _client_fds[i].fd;
|
||||||
|
Reference in New Issue
Block a user