refactor: no cancel timer

This commit is contained in:
Quinten 2025-10-22 15:37:13 +02:00
parent 728638b1e4
commit c49b259862

View File

@ -1,22 +1,26 @@
#include "webserv/log/Log.hpp"
#include <webserv/client/Client.hpp>
#include <webserv/handler/AHandler.hpp>
#include <webserv/handler/URI.hpp>
#include <webserv/http/HttpRequest.hpp>
#include <webserv/http/HttpResponse.hpp>
#include <webserv/client/Client.hpp>
#include <memory>
#include <chrono>
#include <memory>
#include <string>
AHandler::AHandler(const HttpRequest &request, HttpResponse &response) : request_(request), response_(response) {}
AHandler::~AHandler()
{
cancelTimer();
// cancelTimer();
}
void AHandler::startTimer()
{
timerSocket_ = std::make_unique<TimerSocket>(std::chrono::milliseconds(5000));
timerSocket_ = std::make_unique<TimerSocket>(
std::chrono::milliseconds(request_.getUri().getConfig()->get<int>("timeout").value_or(30)) * 1000);
timerSocket_->setCallback([this]() { handleTimeout(); });
timerSocket_->activate();
@ -27,9 +31,9 @@ void AHandler::startTimer()
void AHandler::cancelTimer()
{
if (timerSocket_)
{
request_.getClient().removeSocket(timerSocket_.get());
timerSocket_ = nullptr;
}
// if (timerSocket_)
// {
// request_.getClient().removeSocket(timerSocket_.get());
// timerSocket_ = nullptr;
// }
}