fix wg client hang after some time (#297)

wg portal doesn't know client disconnect causing msg overstocked in queue, make
entire peer packet process pipeline hang.
This commit is contained in:
Sijie.Sun
2024-08-31 12:44:12 +08:00
committed by GitHub
parent 6964fb71fc
commit 2058dbc470
3 changed files with 43 additions and 9 deletions

View File

@@ -19,6 +19,13 @@ impl MpscTunnelSender {
self.0.send(item).await.with_context(|| "send error")?;
Ok(())
}
pub fn try_send(&self, item: ZCPacket) -> Result<(), TunnelError> {
self.0.try_send(item).map_err(|e| match e {
tachyonix::TrySendError::Full(_) => TunnelError::BufferFull,
tachyonix::TrySendError::Closed(_) => TunnelError::Shutdown,
})
}
}
pub struct MpscTunnel<T> {