Slightly rework locking with pull_project

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

@ -646,6 +646,7 @@ 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); std::lock_guard<std::mutex> lock(task_assignment_mutex);
auto found_it = encountered_items.find(r->package->name); auto found_it = encountered_items.find(r->package->name);
if (found_it != encountered_items.end()) { if (found_it != encountered_items.end()) {
@ -660,8 +661,9 @@ std::string CiLogic::queue_pull_tarball(std::vector<std::shared_ptr<PackageConf>
r->packaging_commit = existing_item->first_pkgconf->packaging_commit; r->packaging_commit = existing_item->first_pkgconf->packaging_commit;
r->upstream_commit = existing_item->first_pkgconf->upstream_commit; r->upstream_commit = existing_item->first_pkgconf->upstream_commit;
r->sync(); 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;
@ -675,7 +677,11 @@ std::string CiLogic::queue_pull_tarball(std::vector<std::shared_ptr<PackageConf>
}, },
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(
@ -686,8 +692,10 @@ std::string CiLogic::queue_pull_tarball(std::vector<std::shared_ptr<PackageConf>
}, },
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