allow a request to be processed in a job

Now we allow a request to be passed into a job queue,
and after the job finishes the request is passed into
a controller again. In order to achieve this we have
a requests queue in System, when we put a request
to the job this Request structure is preserved in the
queue and for a new request a new Request is added to
the queue.

while here:
- remove App::Lock()/Unlock(), use scoped locking
- fix: Plugin now has a Call method which takes ModelConnector
  and a logger (used in multithreaded environment)
- BaseThread has a main_model_connector pointer
  to the main (from the main thread) model connector
- the FastCGI structure fcgi_request moved from App to Request
- some methods for handling requests moved from App to Request
- small refactoring in main.cpp
- add Http class (a http client)
This commit is contained in:
2022-07-25 14:21:21 +02:00
parent b2d92b85a0
commit 979ef907fe
65 changed files with 7018 additions and 4437 deletions

View File

@@ -170,6 +170,7 @@ Error Functions::CheckSpecialFile(const Item & item)
cur->mount = system->mounts.GetEmptyMount();
system->mounts.ReadMounts(item.item_content.content_raw);
system->mounts.CalcCurMount(cur->request);
cur->mount = system->mounts.pmount;
templates->ReadNewIndexTemplates();
templates->ReadNewChangeTemplates();
@@ -275,7 +276,7 @@ void Functions::CreateFunctions()
Add(fun_who);
Add(fun_vim);
plugin->Call((Session*)0, WINIX_CREATE_FUNCTIONS);
plugin->Call(WINIX_CREATE_FUNCTIONS);
}
@@ -312,10 +313,15 @@ void Functions::Finish()
bool Functions::Parse()
{
return function_parser.Parse(cur, db, this, system);
return function_parser.Parse(cur->request, &system->dirs, this);
}
bool Functions::ParseOnlyDirs()
{
return function_parser.ParseDirs(cur->request, &system->dirs);
}
void Functions::SetDefaultFunctionForFile()
{
@@ -494,6 +500,56 @@ void Functions::MakeFunction()
}
void Functions::ContinueMakeFunction()
{
if( !cur->request->function )
{
cur->request->status = WINIX_ERR_NO_FUNCTION;
log << log1 << "Functions: no function (neither cat nor ls)" << logend;
return;
}
// if( !system->DirsHaveReadExecPerm() ||
// !system->HasReadExecAccess(cur->request->function->fun) ||
// !cur->request->function->HasAccess() )
// {
// cur->request->status = WINIX_ERR_PERMISSION_DENIED;
// return;
// }
if( cur->request->method == Request::get )
{
log << log4 << "Functions: continuing method get for request " << cur->request
<< " for function " << cur->request->function->fun.url << logend;
cur->request->function->ContinueMakeGet();
}
else
if( cur->request->method == Request::post )
{
log << log4 << "Functions: continuing method post for request " << cur->request
<< " for function " << cur->request->function->fun.url << logend;
cur->request->function->ContinueMakePost();
}
else
if( cur->request->method == Request::head )
{
// do nothing
// !! IMPROVE ME
// we should make a page similar like in a GET request but the content should not be returned only
}
else
if( cur->request->method == Request::delete_ )
{
log << log4 << "Functions: continuing method delete for request " << cur->request
<< " for function " << cur->request->function->fun.url << logend;
cur->request->function->ContinueMakeDelete();
}
else
{
log << log1 << "Functions: cannot continue a request, unknown request method (skipping)" << logend;
}
}