This commit is contained in:
apio 2022-11-03 21:58:25 +01:00
parent f6b4341d39
commit 883310d241
2 changed files with 13 additions and 13 deletions

View File

@ -43,7 +43,7 @@ private:
sockaddr_in m_addr;
int handle_request(Request& req);
int handle_request(Request& req, int fd);
std::string get_client_addr();

View File

@ -210,7 +210,7 @@ void webcxx::App::connection_thread()
int status;
if((status = handle_request(req)))
if((status = handle_request(req, fd)))
{
return;
}
@ -335,7 +335,7 @@ webcxx::Response webcxx::file(const std::string& item_path)
return res;
}
int webcxx::App::handle_request(Request& req)
int webcxx::App::handle_request(Request& req, int fd)
{
Response res(200);
@ -356,8 +356,8 @@ int webcxx::App::handle_request(Request& req)
} catch (...) {
res = error(500);
req.log(res.status);
res.send(m_current_connection_fd);
close(m_current_connection_fd);
res.send(fd);
close(fd);
close(m_socket_fd);
std::rethrow_exception(std::current_exception());
}
@ -372,8 +372,8 @@ int webcxx::App::handle_request(Request& req)
} catch (...) {
res = error(500);
req.log(res.status);
res.send(m_current_connection_fd);
close(m_current_connection_fd);
res.send(fd);
close(fd);
close(m_socket_fd);
std::rethrow_exception(std::current_exception());
}
@ -388,8 +388,8 @@ int webcxx::App::handle_request(Request& req)
} catch (...) {
res = error(500);
req.log(res.status);
res.send(m_current_connection_fd);
close(m_current_connection_fd);
res.send(fd);
close(fd);
close(m_socket_fd);
std::rethrow_exception(std::current_exception());
}
@ -404,8 +404,8 @@ int webcxx::App::handle_request(Request& req)
} catch (...) {
res = error(500);
req.log(res.status);
res.send(m_current_connection_fd);
close(m_current_connection_fd);
res.send(fd);
close(fd);
close(m_socket_fd);
std::rethrow_exception(std::current_exception());
}
@ -419,9 +419,9 @@ int webcxx::App::handle_request(Request& req)
}
req.log(res.status);
if (res.send(m_current_connection_fd) < 0) {
if (res.send(fd) < 0) {
perror("send");
close(m_current_connection_fd);
close(fd);
close(m_socket_fd);
return 1;
}