Slightly rework locking with pull_project

main
Simon Quigley 2 weeks ago
parent 0dced17ef2
commit 1ecec033f1

@ -646,48 +646,56 @@ std::string CiLogic::queue_pull_tarball(std::vector<std::shared_ptr<PackageConf>
try { try {
for (auto &r : repos) { for (auto &r : repos) {
std::lock_guard<std::mutex> lock(task_assignment_mutex); {
auto found_it = encountered_items.find(r->package->name); std::lock_guard<std::mutex> lock(task_assignment_mutex);
if (found_it != encountered_items.end()) { auto found_it = encountered_items.find(r->package->name);
// GHOST pull if (found_it != encountered_items.end()) {
auto existing_item = found_it->second; // GHOST pull
auto existing_item = found_it->second;
// Assign tasks (reuse the same Task objects for "pull"/"tarball")
r->assign_task(job_statuses->at("pull"), existing_item->first_pull_task, r); // Assign tasks (reuse the same Task objects for "pull"/"tarball")
r->assign_task(job_statuses->at("tarball"), existing_item->first_tarball_task, r); r->assign_task(job_statuses->at("pull"), existing_item->first_pull_task, r);
r->assign_task(job_statuses->at("tarball"), existing_item->first_tarball_task, r);
// Point packaging_commit/upstream_commit to the real pkgconf's pointers
r->packaging_commit = existing_item->first_pkgconf->packaging_commit; // Point packaging_commit/upstream_commit to the real pkgconf's pointers
r->upstream_commit = existing_item->first_pkgconf->upstream_commit; r->packaging_commit = existing_item->first_pkgconf->packaging_commit;
r->sync(); r->upstream_commit = existing_item->first_pkgconf->upstream_commit;
r->sync();
continue;
}
} }
else { // REAL pull
// REAL pull auto new_item = std::make_shared<package_conf_item>();
auto new_item = std::make_shared<package_conf_item>(); new_item->first_pkgconf = r;
new_item->first_pkgconf = r;
// Enqueue "pull"
// Enqueue "pull" task_queue->enqueue(
task_queue->enqueue( job_statuses->at("pull"),
job_statuses->at("pull"), [this, r](std::shared_ptr<Log> log) mutable {
[this, r](std::shared_ptr<Log> log) mutable { pull_project(r, log);
pull_project(r, log); r->sync();
r->sync(); },
}, r
r );
);
{
std::lock_guard<std::mutex> lock(task_assignment_mutex);
new_item->first_pull_task = r->get_task_by_jobstatus(job_statuses->at("pull")); new_item->first_pull_task = r->get_task_by_jobstatus(job_statuses->at("pull"));
}
// Enqueue "tarball" // Enqueue "tarball"
task_queue->enqueue( task_queue->enqueue(
job_statuses->at("tarball"), job_statuses->at("tarball"),
[this, r](std::shared_ptr<Log> log) mutable { [this, r](std::shared_ptr<Log> log) mutable {
create_project_tarball(r, log); create_project_tarball(r, log);
r->sync(); r->sync();
}, },
r r
); );
new_item->first_tarball_task = r->get_task_by_jobstatus(job_statuses->at("tarball"));
{
std::lock_guard<std::mutex> lock(task_assignment_mutex);
new_item->first_tarball_task = r->get_task_by_jobstatus(job_statuses->at("tarball"));
encountered_items[r->package->name] = new_item; encountered_items[r->package->name] = new_item;
} }
} }

Loading…
Cancel
Save