bugfix invalid ptr in "ev.data.ptr" after vector<Client> resize/erase

+ persistent connections reintroduced
+ bugfix crash if invalid path in request
This commit is contained in:
LuckyLaszlo
2022-07-31 13:19:11 +02:00
parent af8dc072c1
commit ea3f3a390a
5 changed files with 54 additions and 22 deletions

View File

@@ -15,8 +15,8 @@ void Webserv::_read_request(Client *client)
char buf[BUFSIZE+1];
ssize_t ret;
std::cerr << "recv()\n";
ret = ::recv(client->fd, buf, BUFSIZE, 0);
std::cerr << "recv() on fd(" << client->fd << ") returned = " << ret << "\n" ;
if (ret == -1)
{
std::perror("err recv()");
@@ -25,6 +25,11 @@ void Webserv::_read_request(Client *client)
_close_client(client->fd);
return ;
}
if (ret == 0) // Not sure what to do in case of 0. Just close ?
{
_close_client(client->fd);
return ;
}
/*
if (ret == BUFSIZE)
// send error like "request too long" to client
@@ -33,5 +38,5 @@ void Webserv::_read_request(Client *client)
buf[ret] = '\0';
client->raw_request.append(buf);
_epoll_update(client->fd, EPOLLOUT, EPOLL_CTL_MOD, client);
_epoll_update(client->fd, EPOLLOUT, EPOLL_CTL_MOD);
}