Fix deadlock error
This commit is contained in:
parent
dae68efaae
commit
b771a40a3d
|
@ -194,11 +194,7 @@ impl LoxServerContext {
|
||||||
accounted_for_bridges,
|
accounted_for_bridges,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let mut ba_clone = self.ba.lock().unwrap();
|
let unaccounted_for = self.ba.lock().unwrap().find_and_remove_unaccounted_for_bridges(accounted_for_bridges);
|
||||||
let total_reachable = ba_clone.bridge_table.reachable.len();
|
|
||||||
match total_reachable.cmp(&accounted_for_bridges.len()) {
|
|
||||||
Ordering::Greater => {
|
|
||||||
let unaccounted_for = ba_clone.find_and_remove_unaccounted_for_bridges(accounted_for_bridges);
|
|
||||||
for bridgeline in unaccounted_for {
|
for bridgeline in unaccounted_for {
|
||||||
match self.replace_with_new(bridgeline) {
|
match self.replace_with_new(bridgeline) {
|
||||||
lox_library::ReplaceSuccess::Replaced => {
|
lox_library::ReplaceSuccess::Replaced => {
|
||||||
|
@ -217,18 +213,13 @@ impl LoxServerContext {
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Ordering::Less => println!("Something unexpected occurred: The number of reachable bridges should not be less than those updated from rdsys"),
|
|
||||||
_ => (),
|
|
||||||
|
|
||||||
}
|
|
||||||
// Finally, assign any extra_bridges to new buckets if there are enough
|
// Finally, assign any extra_bridges to new buckets if there are enough
|
||||||
while self.extra_bridges.lock().unwrap().len() >= MAX_BRIDGES_PER_BUCKET {
|
while self.extra_bridges.lock().unwrap().len() >= MAX_BRIDGES_PER_BUCKET {
|
||||||
let bucket = self.remove_extra_bridges();
|
let bucket = self.remove_extra_bridges();
|
||||||
// TODO: Decide the circumstances under which a bridge is allocated to an open_inv or spare bucket,
|
// TODO: Decide the circumstances under which a bridge is allocated to an open_inv or spare bucket,
|
||||||
// eventually also do some more fancy grouping of new resources, i.e., by type or region
|
// eventually also do some more fancy grouping of new resources, i.e., by type or region
|
||||||
let mut db_obj = self.db.lock().unwrap();
|
let mut db_obj = self.db.lock().unwrap();
|
||||||
match ba_clone.add_spare_bucket(bucket, &mut db_obj) {
|
match self.ba.lock().unwrap().add_spare_bucket(bucket, &mut db_obj) {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Error: {:?}", e);
|
println!("Error: {:?}", e);
|
||||||
|
@ -238,6 +229,9 @@ impl LoxServerContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Any remaining extra bridges should be cleared from the Lox Context after each sync
|
||||||
|
// Currently bridgetable updating behaviour does not occur without receiving a resource list
|
||||||
|
// from rdsys so if the extra bridge is still working, it can be added to the table later
|
||||||
self.extra_bridges.lock().unwrap().clear();
|
self.extra_bridges.lock().unwrap().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -803,10 +797,10 @@ mod tests {
|
||||||
reachable_expected_length,
|
reachable_expected_length,
|
||||||
"Unexpected number of reachable bridges"
|
"Unexpected number of reachable bridges"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
// Extra bridges should be cleared from the Lox Context after each sync
|
||||||
th.context.extra_bridges.lock().unwrap().len(),
|
assert!(
|
||||||
0,
|
th.context.extra_bridges.lock().unwrap().is_empty(),
|
||||||
"Unexpected number of extra bridges"
|
"Extra bridges should be empty after syncUnexpected number of extra bridges"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue