summaryrefslogtreecommitdiffstats
path: root/src/orchestrator/orchestrator.rs
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-02-07 12:12:17 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-02-08 09:37:04 +0100
commitc46a2ee433b6de462cea1d8782c73f76553ecc8a (patch)
tree3b7a67c7a58bb4afda8362044b9e390273e84abb /src/orchestrator/orchestrator.rs
parent2d82860bbd867a328fa1ab21e77705439ba4636b (diff)
Fix: Do not borrow mutable twice
This fixes a bug which caused butido to crash in case of `else` in the snippet changed here. This was because in the `else`-case, we borrow mutably what was already mutably borrowed, causing a panic. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Tested-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/orchestrator/orchestrator.rs')
-rw-r--r--src/orchestrator/orchestrator.rs29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/orchestrator/orchestrator.rs b/src/orchestrator/orchestrator.rs
index f5dd8cb..a1f8a99 100644
--- a/src/orchestrator/orchestrator.rs
+++ b/src/orchestrator/orchestrator.rs
@@ -268,20 +268,23 @@ impl<'a> Orchestrator<'a> {
.filter(|j| j.1.jobdef.dependencies.contains(job.1.jobdef.job.uuid()))
.map(|j| j.2.clone())
});
- } else {
- *job.3.borrow_mut() = {
- let depending_on_job = jobs.iter()
- .filter(|j| j.1.jobdef.dependencies.contains(job.1.jobdef.job.uuid()))
- .map(|j| j.2.clone())
- .collect::<Vec<Sender<JobResult>>>();
-
- if depending_on_job.is_empty() {
- None
- } else {
- Some(depending_on_job)
- }
- };
+
+ continue;
}
+
+ // else, but not in else {} because of borrowing
+ *job.3.borrow_mut() = {
+ let depending_on_job = jobs.iter()
+ .filter(|j| j.1.jobdef.dependencies.contains(job.1.jobdef.job.uuid()))
+ .map(|j| j.2.clone())
+ .collect::<Vec<Sender<JobResult>>>();
+
+ if depending_on_job.is_empty() {
+ None
+ } else {
+ Some(depending_on_job)
+ }
+ };
}
// Find the id of the root task