mirror of
https://github.com/threefoldtech/mycelium.git
synced 2026-10-23 06:01:16 +00:00
Only return a writeguard for routes if there are routes
Return None in case the entry is queried or not existing, as we semantically don't have routes in this case. This matches the implementatin of routes_mut on the WriteGuard Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
1 parent
94afd94f27
commit
c856a72bca
1 file changed
+14
-10
@@ -201,16 +201,20 @@ impl RoutingTable {
|
||||
.exact_match(subnet_address, subnet.prefix_len().into())?
|
||||
.clone();
|
||||
|
||||
Some(WriteGuard {
|
||||
routing_table: self,
|
||||
// If we didn't find a route list in the route table we create a new empty list,
|
||||
// therefore we immediately own it.
|
||||
value,
|
||||
exists: true,
|
||||
subnet,
|
||||
expired_route_entry_sink: self.expired_route_entry_sink.clone(),
|
||||
cancellation_token: self.cancel_token.clone(),
|
||||
})
|
||||
if matches!(*value, SubnetEntry::Exists { .. }) {
|
||||
Some(WriteGuard {
|
||||
routing_table: self,
|
||||
// If we didn't find a route list in the route table we create a new empty list,
|
||||
// therefore we immediately own it.
|
||||
value,
|
||||
exists: true,
|
||||
subnet,
|
||||
expired_route_entry_sink: self.expired_route_entry_sink.clone(),
|
||||
cancellation_token: self.cancel_token.clone(),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Adds a new [`Subnet`] to the `RoutingTable`. The returned [`WriteGuard`] can be used to
|
||||
|
||||
Reference in new issue
Block a user