diff --git a/winixd/core/app.cpp b/winixd/core/app.cpp index 1980f4c..82cdc40 100644 --- a/winixd/core/app.cpp +++ b/winixd/core/app.cpp @@ -934,33 +934,12 @@ void App::Start() fcgi_request = &cur.request->fcgi_request; } - WaitForRequestsToFinish(); -} - - -/* - * wait for requests from the jobs - */ -void App::WaitForRequestsToFinish() -{ - bool is_req_tab_empty = false; - - { - Winix::Lock lock(synchro); - system.DeleteOldRequests(); - is_req_tab_empty = system.req_tab.empty(); - } - - while( is_req_tab_empty ) - { - log << log3 << "App: waiting for requests to finish..." << logend << logsave; - sleep(1); - - { - Winix::Lock lock(synchro); - is_req_tab_empty = system.req_tab.empty(); - } - } + /* + * we do not wait for some job requests to finish (if there are such requests) + * the job loop will exit immediately when a synchro->is_stop_signal is defined + * and there is no need to process such requests (the www server will return a 50x error + * to the client) + */ } diff --git a/winixd/core/app.h b/winixd/core/app.h index b453598..4805743 100644 --- a/winixd/core/app.h +++ b/winixd/core/app.h @@ -217,7 +217,6 @@ private: bool DoDatabaseMigration(); bool TryToMakeDatabaseMigration(); - void WaitForRequestsToFinish(); // !! IMPROVE ME diff --git a/winixd/core/job.cpp b/winixd/core/job.cpp index 444baea..fbd45cf 100644 --- a/winixd/core/job.cpp +++ b/winixd/core/job.cpp @@ -198,6 +198,7 @@ return true; second thread */ + // second thread (objects locked) bool Job::SignalReceived() { @@ -430,7 +431,6 @@ void Job::RemoveOldRequest(Request * request) } - } // namespace Winix diff --git a/winixd/core/job.h b/winixd/core/job.h index 110aa6e..7106b88 100644 --- a/winixd/core/job.h +++ b/winixd/core/job.h @@ -138,6 +138,7 @@ private: void DoRequestContinuationJob(JobTask & job_task, size_t priority); void DoWinixJob(pt::Space & job); void RemoveOldRequest(Request * request); + void RemoveAllJobsRequests(); PluginRes DoRequestJobs(JobTask & task, long job_id, size_t priority); }; diff --git a/winixd/core/system.cpp b/winixd/core/system.cpp index c5eea06..10acc72 100644 --- a/winixd/core/system.cpp +++ b/winixd/core/system.cpp @@ -1526,9 +1526,9 @@ void System::DeleteOldRequests(bool leave_one_object) while( i != req_tab.end() ) { // leave at least one object (even if it is finished) - if( i->run_state == Request::RunState::finished && (!leave_one_object || req_tab.size() > 1) ) + if( (i->run_state == Request::RunState::finished || i->run_state == Request::RunState::not_assigned) && (!leave_one_object || req_tab.size() > 1) ) { - log << log3 << "System: removing finished request " << cur->request << logend; + log << log3 << "System: removing a finished or not assigned request " << cur->request << logend; std::list::iterator old_i = i; ++i; req_tab.erase(old_i);