mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-15 22:27:26 +08:00
fix self peer route info not exist when starting (#595)
This commit is contained in:
@@ -391,6 +391,13 @@ impl SyncedRouteInfo {
|
||||
&route_info,
|
||||
)?;
|
||||
|
||||
let peer_id_raw = raw_route_info
|
||||
.get_field_by_name("peer_id")
|
||||
.unwrap()
|
||||
.as_u32()
|
||||
.unwrap();
|
||||
assert_eq!(peer_id_raw, route_info.peer_id);
|
||||
|
||||
// time between peers may not be synchronized, so update last_update to local now.
|
||||
// note only last_update with larger version will be updated to local saved peer info.
|
||||
route_info.last_update = Some(SystemTime::now().into());
|
||||
@@ -1644,8 +1651,6 @@ impl RouteSessionManager {
|
||||
) {
|
||||
let mut last_sync = Instant::now();
|
||||
loop {
|
||||
let mut first_time = true;
|
||||
|
||||
loop {
|
||||
let Some(service_impl) = service_impl.clone().upgrade() else {
|
||||
return;
|
||||
@@ -1655,11 +1660,6 @@ impl RouteSessionManager {
|
||||
return;
|
||||
};
|
||||
|
||||
if first_time {
|
||||
first_time = false;
|
||||
service_impl.update_my_infos().await;
|
||||
}
|
||||
|
||||
// if we are initiator, we should ensure the dst has the session.
|
||||
let sync_as_initiator = if last_sync.elapsed().as_secs() > 10 {
|
||||
last_sync = Instant::now();
|
||||
@@ -2023,6 +2023,9 @@ impl PeerRoute {
|
||||
return;
|
||||
};
|
||||
|
||||
// make sure my_peer_id is in the peer_infos.
|
||||
self.service_impl.update_my_infos().await;
|
||||
|
||||
peer_rpc.rpc_server().registry().register(
|
||||
OspfRouteRpcServer::new(self.session_mgr.clone()),
|
||||
&self.global_ctx.get_network_name(),
|
||||
|
||||
Reference in New Issue
Block a user