Add fix for failure to replace bridges
- Change text for disabled functionality for blocked bridges
This commit is contained in:
parent
13d1bc8b1d
commit
da4d7c962f
|
@ -80,6 +80,7 @@ pub struct LoxServerContext {
|
||||||
pub db: Arc<Mutex<BridgeDb>>,
|
pub db: Arc<Mutex<BridgeDb>>,
|
||||||
pub ba: Arc<Mutex<BridgeAuth>>,
|
pub ba: Arc<Mutex<BridgeAuth>>,
|
||||||
pub extra_bridges: Arc<Mutex<Vec<BridgeLine>>>,
|
pub extra_bridges: Arc<Mutex<Vec<BridgeLine>>>,
|
||||||
|
pub unreplaced_bridges: Arc<Mutex<Vec<BridgeLine>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LoxServerContext {
|
impl LoxServerContext {
|
||||||
|
@ -100,6 +101,11 @@ impl LoxServerContext {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn new_unreplaced_bridge(&self, bridge: BridgeLine) {
|
||||||
|
let mut unreplaced_bridges = self.unreplaced_bridges.lock().unwrap();
|
||||||
|
unreplaced_bridges.push(bridge);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn allocate_leftover_bridges(&self) {
|
pub fn allocate_leftover_bridges(&self) {
|
||||||
let mut ba_obj = self.ba.lock().unwrap();
|
let mut ba_obj = self.ba.lock().unwrap();
|
||||||
let mut db_obj = self.db.lock().unwrap();
|
let mut db_obj = self.db.lock().unwrap();
|
||||||
|
|
|
@ -184,6 +184,7 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
||||||
db: Arc::new(Mutex::new(bridgedb)),
|
db: Arc::new(Mutex::new(bridgedb)),
|
||||||
ba: Arc::new(Mutex::new(lox_auth)),
|
ba: Arc::new(Mutex::new(lox_auth)),
|
||||||
extra_bridges: Arc::new(Mutex::new(Vec::new())),
|
extra_bridges: Arc::new(Mutex::new(Vec::new())),
|
||||||
|
unreplaced_bridges: Arc::new(Mutex::new(Vec::new())),
|
||||||
};
|
};
|
||||||
|
|
||||||
while let Some(cmd) = context_rx.recv().await {
|
while let Some(cmd) = context_rx.recv().await {
|
||||||
|
@ -222,6 +223,21 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
||||||
info: info_bytes,
|
info: info_bytes,
|
||||||
};
|
};
|
||||||
println!("Now it's a bridgeline: {:?}", bridgeline);
|
println!("Now it's a bridgeline: {:?}", bridgeline);
|
||||||
|
if context.unreplaced_bridges.lock().unwrap().len() > 0 {
|
||||||
|
println!("BridgeLine to be replaced: {:?}", bridgeline);
|
||||||
|
let res = context.replace_with_new(bridgeline);
|
||||||
|
if res {
|
||||||
|
println!(
|
||||||
|
"BridgeLine successfully replaced: {:?}",
|
||||||
|
bridgeline
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Add the bridge to the list of unreplaced bridges in the Lox context and try
|
||||||
|
// again to replace at the next update (nothing changes in the Lox Authority)
|
||||||
|
println!("'Gone' BridgeLine NOT replaced, saved for next update! : {:?}", bridgeline);
|
||||||
|
context.new_unreplaced_bridge(bridgeline);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if count < MAX_BRIDGES_PER_BUCKET-1 {
|
if count < MAX_BRIDGES_PER_BUCKET-1 {
|
||||||
bucket[count] = bridgeline;
|
bucket[count] = bridgeline;
|
||||||
count += 1;
|
count += 1;
|
||||||
|
@ -234,6 +250,7 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Handle the extra buckets that were not allocated already
|
// Handle the extra buckets that were not allocated already
|
||||||
if count != 0 {
|
if count != 0 {
|
||||||
for val in 0..count {
|
for val in 0..count {
|
||||||
|
@ -287,7 +304,7 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
||||||
let bucket = context.remove_extra_bridges();
|
let bucket = context.remove_extra_bridges();
|
||||||
context.add_spare_bucket(bucket);
|
context.add_spare_bucket(bucket);
|
||||||
}
|
}
|
||||||
//TODO probably do something else here
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -326,7 +343,27 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
||||||
uid_fingerprint: resource_uid,
|
uid_fingerprint: resource_uid,
|
||||||
info: info_bytes,
|
info: info_bytes,
|
||||||
};
|
};
|
||||||
/* // Marking bridges as unreachable is reserved for blocked bridges
|
println!("BridgeLine to be replaced: {:?}", bridgeline);
|
||||||
|
let res = context.replace_with_new(bridgeline);
|
||||||
|
if res {
|
||||||
|
println!(
|
||||||
|
"BridgeLine successfully replaced: {:?}",
|
||||||
|
bridgeline
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Add the bridge to the list of unreplaced bridges in the Lox context and try
|
||||||
|
// again to replace at the next update (nothing changes in the Lox Authority)
|
||||||
|
println!("'Gone' BridgeLine NOT replaced, saved for next update! : {:?}", bridgeline);
|
||||||
|
context.new_unreplaced_bridge(bridgeline);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Functionality for marking bridges as unreachable/blocked is currently not enabled as there is not
|
||||||
|
yet a reliable way to determine that a bridge is blocked. This means that migrations to unblocked bridges do not
|
||||||
|
currently work but can be easily enabled with a list of `blocked resources` from rdsys or another source with something
|
||||||
|
like the following:
|
||||||
println!("BridgeLine to be removed: {:?}", bridgeline);
|
println!("BridgeLine to be removed: {:?}", bridgeline);
|
||||||
let res = context.add_unreachable(bridgeline);
|
let res = context.add_unreachable(bridgeline);
|
||||||
if res {
|
if res {
|
||||||
|
@ -339,21 +376,6 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
||||||
//TODO probably do something else here
|
//TODO probably do something else here
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
println!("BridgeLine to be replaced: {:?}", bridgeline);
|
|
||||||
let res = context.replace_with_new(bridgeline);
|
|
||||||
if res {
|
|
||||||
println!(
|
|
||||||
"BridgeLine successfully replaced: {:?}",
|
|
||||||
bridgeline
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
println!("'Gone' BridgeLine NOT replaced, marked removed!! : {:?}", bridgeline);
|
|
||||||
//TODO probably do something else here
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
context.allocate_leftover_bridges();
|
context.allocate_leftover_bridges();
|
||||||
context.encrypt_table();
|
context.encrypt_table();
|
||||||
sleep(Duration::from_millis(1)).await;
|
sleep(Duration::from_millis(1)).await;
|
||||||
|
|
Loading…
Reference in New Issue