diff --git a/cpp/ci_logic.cpp b/cpp/ci_logic.cpp index 56c048b..9c2b290 100644 --- a/cpp/ci_logic.cpp +++ b/cpp/ci_logic.cpp @@ -1149,24 +1149,22 @@ std::string CiLogic::queue_pull_tarball(std::vector std::shared_ptr tarball_task = std::make_shared(); task_queue->enqueue( job_statuses->at("pull"), - [this, r, &task_queue, &tarball_task, job_statuses](std::shared_ptr log) mutable { - std::shared_ptr pkgconf = log->get_task_context()->get_parent_packageconf(); - if (pull_project(pkgconf, log)) { - task_queue->enqueue( - job_statuses->at("tarball"), - [this, r](std::shared_ptr log) mutable { - bool tarball_ok = create_project_tarball(r, log); - }, - r - ); - tarball_task = r->get_task_by_jobstatus(job_statuses->at("tarball")); - } + [this, r](std::shared_ptr log) mutable { + pull_project(r, log); }, r ); - new_item->first_pull_task = r->get_task_by_jobstatus(job_statuses->at("pull")); - new_item->first_tarball_task = tarball_task; + + task_queue->enqueue( + job_statuses->at("tarball"), + [this, r](std::shared_ptr log) mutable { + create_project_tarball(r, log); + }, + r + ); + new_item->first_tarball_task = r->get_task_by_jobstatus(job_statuses->at("tarball")); + new_item->first_pkgconf = r; new_item->packaging_commit = r->packaging_commit; diff --git a/cpp/task_queue.cpp b/cpp/task_queue.cpp index 4c72937..875b499 100644 --- a/cpp/task_queue.cpp +++ b/cpp/task_queue.cpp @@ -95,17 +95,22 @@ void TaskQueue::worker_thread() { bool found_valid = false; // Iterate through the set until a valid task is found while (it != tasks_.end()) { - std::shared_ptr it_task = *it; - task_to_execute = it_task; + { + std::shared_ptr it_task = *it; + task_to_execute = it_task; + } + int pkgconf_id = task_to_execute->get_parent_packageconf()->id; - std::lock_guard lock(running_pkgconfs_mutex_); - auto running_pkgconf_it = std::find_if(running_pkgconfs_.begin(), running_pkgconfs_.end(), - [&pkgconf_id](const std::shared_ptr& pkgconf) { return pkgconf->id == pkgconf_id; }); + { + std::lock_guard lock(running_pkgconfs_mutex_); + auto running_pkgconf_it = std::find_if(running_pkgconfs_.begin(), running_pkgconfs_.end(), + [&pkgconf_id](const std::shared_ptr& pkgconf) { return pkgconf->id == pkgconf_id; }); - if (running_pkgconf_it != running_pkgconfs_.end()) { - ++it; // Move to the next task - continue; + if (running_pkgconf_it != running_pkgconfs_.end()) { + ++it; // Move to the next task + continue; + } } // Task is valid to execute