fix: correctly clear after a request when an exception has been thrown
This commit is contained in:
parent
dda325bbbf
commit
1655ae3562
|
@ -766,25 +766,12 @@ void App::ProcessRequestThrow()
|
|||
|
||||
void App::ProcessRequest()
|
||||
{
|
||||
system.load_avg.StartRequest(cur.request);
|
||||
log << log2 << config.log_delimiter << logend;
|
||||
|
||||
try
|
||||
{
|
||||
system.load_avg.StartRequest(cur.request);
|
||||
log << log2 << config.log_delimiter << logend;
|
||||
|
||||
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,26 +785,28 @@ void App::ProcessRequest()
|
|||
{
|
||||
log << log1 << "App: there was an unknown exception" << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void App::ClearAfterRequest()
|
||||
{
|
||||
try
|
||||
{
|
||||
// simple operations which should not throw an exception
|
||||
cur.request->Clear();
|
||||
cur.session->ClearAfterRequest();
|
||||
cur.session = session_manager.GetTmpSession();
|
||||
cur.mount = system.mounts.GetEmptyMount();
|
||||
system.mounts.pmount = cur.mount; // IMPROVE ME system.mounts.pmount will be removed
|
||||
// send_data_buf doesn't have to be cleared and it is better to not clear it (optimizing)
|
||||
if( cur.request->run_state == Request::RunState::normal_run )
|
||||
{
|
||||
cur.request->FinishRequest();
|
||||
system.load_avg.StopRequest(cur.request);
|
||||
}
|
||||
|
||||
model_connector.set_winix_request(nullptr);
|
||||
model_connector.set_winix_session(nullptr);
|
||||
model_connector.set_winix_session_logger(nullptr);
|
||||
SaveSessionsIfNeeded();
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
log << log1 << "App: an exception when finishing a request" << logend;
|
||||
}
|
||||
|
||||
log << logendrequest;
|
||||
try
|
||||
{
|
||||
if( cur.request->run_state == Request::RunState::finished )
|
||||
{
|
||||
ClearAfterRequest();
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
|
@ -826,6 +815,24 @@ void App::ClearAfterRequest()
|
|||
}
|
||||
|
||||
|
||||
void App::ClearAfterRequest()
|
||||
{
|
||||
// simple operations which should not throw an exception
|
||||
cur.request->Clear();
|
||||
cur.session->ClearAfterRequest();
|
||||
cur.session = session_manager.GetTmpSession();
|
||||
cur.mount = system.mounts.GetEmptyMount();
|
||||
system.mounts.pmount = cur.mount; // IMPROVE ME system.mounts.pmount will be removed
|
||||
// send_data_buf doesn't have to be cleared and it is better to not clear it (optimizing)
|
||||
|
||||
model_connector.set_winix_request(nullptr);
|
||||
model_connector.set_winix_session(nullptr);
|
||||
model_connector.set_winix_session_logger(nullptr);
|
||||
|
||||
log << logendrequest;
|
||||
}
|
||||
|
||||
|
||||
bool App::InitializeRequestForFastCGI(Request & request)
|
||||
{
|
||||
bool request_initialized = false;
|
||||
|
|
Loading…
Reference in New Issue