You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
async fn send_to(&mut self, p: &[u8], addr: SocketAddr) -> Result<usize> {
// ...
let mut perm = if let Some(perm) = self.perm_map.find(&addr) {
*perm
} else {
let perm = Permission::default();
self.perm_map.insert(&addr, perm);
perm
};
let mut result = Ok(());
for _ in 0..MAX_RETRY_ATTEMPTS {
result = self.create_perm(&mut perm, addr).await;
if let Err(err) = &result {
if !Error::ErrTryAgain.equal(err) {
break;
}
}
}
The perm variable is read from perm_map but never written back to it. So, every time send_to is called, it will get a Idle permission, which triggers a new CreatePermission on the create_perm function.
After the create_perm is called, the perm variable should be set back to perm_map.
Besides that, there is no Lifetime tracking. If we didn't receive any packet from a given address for more than 300 seconds, then the Permission for that given address should be removed from the perm_map. Because we must update the permission.
The text was updated successfully, but these errors were encountered:
Besides that, there is no Lifetime tracking. If we didn't receive any packet from a given address for more than 300 seconds, then the Permission for that given address should be removed from the perm_map. Because we must update the permission.
Could you confirm this? Upon closer inspection I've found a reference to a timed refresh of permissions:
From the source code
The
perm
variable is read fromperm_map
but never written back to it. So, every timesend_to
is called, it will get a Idle permission, which triggers a new CreatePermission on thecreate_perm
function.After the
create_perm
is called, theperm
variable should be set back toperm_map
.Besides that, there is no Lifetime tracking. If we didn't receive any packet from a given address for more than 300 seconds, then the Permission for that given address should be removed from the
perm_map
. Because we must update the permission.The text was updated successfully, but these errors were encountered: