From 6d256e6512d4dbf529c7cc57f851789db6904d17 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Fri, 25 Aug 2023 16:24:27 +0200 Subject: [PATCH] fix: correctly set a Request::RunState::job_run flag to the background request The flag should be set to the task.request and not to the cur->request. The cur->request could have been already changed by the main thread. --- winixd/core/job.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/winixd/core/job.cpp b/winixd/core/job.cpp index 1fadcbf..f67fc31 100644 --- a/winixd/core/job.cpp +++ b/winixd/core/job.cpp @@ -273,26 +273,20 @@ void Job::DoJob(JobTask & task, size_t priority) if( task.request ) { Cur local_cur; - - // is this correct? we can read the task.request->session ... from the second thread? - // chyba tak bo ta struktura zostaje na stosie specjalnie dla joba do uzytku - local_cur.request = task.request; + local_cur.request->run_state = Request::RunState::job_run; local_cur.session = task.request->session; local_cur.mount = task.request->mount; - cur->request->run_state = Request::RunState::job_run; res = plugin->Call(model_connector, &log, &local_cur, WINIX_JOB, &task.job, nullptr, task.job_type, task.job_id); log << logsave; { Winix::Lock lock(synchro); - cur->request = local_cur.request; - cur->session = local_cur.session; - cur->mount = local_cur.mount; - // winix templates functions uses its own cur (global pointer in TemplatesFunctions namespace) - // so we have to set it correctly + Cur old_cur = *cur; + *cur = local_cur; DoRequestContinuationJob(task, priority); + *cur = old_cur; } } else