fix: correctly clear after a request when an exception has been thrown

This commit is contained in:
Tomasz Sowa 2023-05-16 15:31:13 +02:00
parent dda325bbbf
commit 1655ae3562
Signed by: tomasz.sowa
GPG Key ID: 662CC1438638588B
1 changed files with 37 additions and 30 deletions

View File

@ -765,26 +765,13 @@ void App::ProcessRequestThrow()
void App::ProcessRequest()
{
try
{
system.load_avg.StartRequest(cur.request);
log << log2 << config.log_delimiter << logend;
try
{
ProcessRequestThrow();
if( cur.request->run_state == Request::RunState::normal_run )
{
cur.request->FinishRequest();
system.load_avg.StopRequest(cur.request);
}
SaveSessionsIfNeeded();
if( cur.request->run_state == Request::RunState::finished )
{
ClearAfterRequest();
}
}
catch(const std::exception & e)
{
@ -798,12 +785,37 @@ void App::ProcessRequest()
{
log << log1 << "App: there was an unknown exception" << logend;
}
try
{
if( cur.request->run_state == Request::RunState::normal_run )
{
cur.request->FinishRequest();
system.load_avg.StopRequest(cur.request);
}
SaveSessionsIfNeeded();
}
catch(...)
{
log << log1 << "App: an exception when finishing a request" << logend;
}
try
{
if( cur.request->run_state == Request::RunState::finished )
{
ClearAfterRequest();
}
}
catch(...)
{
log << log1 << "App: an exception when clearing after a request" << logend;
}
}
void App::ClearAfterRequest()
{
try
{
// simple operations which should not throw an exception
cur.request->Clear();
@ -819,11 +831,6 @@ void App::ClearAfterRequest()
log << logendrequest;
}
catch(...)
{
log << log1 << "App: an exception when clearing after a request" << logend;
}
}
bool App::InitializeRequestForFastCGI(Request & request)