Lower timeout interval
This commit is contained in:
parent
4038d125db
commit
28ebfec3ca
4 changed files with 10 additions and 13 deletions
|
|
@ -47,7 +47,7 @@ pub async fn daemon_main() -> Result<()> {
|
|||
|
||||
let mut _tun = tun::TunInterface::new()?;
|
||||
_tun.set_ipv4_addr(Ipv4Addr::from([192, 168, 1, 10]))?;
|
||||
_tun.set_timeout(Some(std::time::Duration::from_secs(1)))?;
|
||||
_tun.set_timeout(Some(std::time::Duration::from_millis(10)))?;
|
||||
let tun = tun::tokio::TunInterface::new(_tun)?;
|
||||
|
||||
let private_key = parse_secret_key("GNqIAOCRxjl/cicZyvkvpTklgQuUmGUIEkH7IXF/sEE=")?;
|
||||
|
|
|
|||
|
|
@ -101,12 +101,12 @@ impl Interface {
|
|||
|
||||
let outgoing = async move {
|
||||
loop {
|
||||
log::debug!("starting loop...");
|
||||
// log::debug!("starting loop...");
|
||||
let mut buf = [0u8; 3000];
|
||||
|
||||
let src = {
|
||||
log::debug!("awaiting read...");
|
||||
let src = match timeout(Duration::from_secs(2), tun.write().await.recv(&mut buf[..])).await {
|
||||
// log::debug!("awaiting read...");
|
||||
let src = match timeout(Duration::from_millis(10), tun.write().await.recv(&mut buf[..])).await {
|
||||
Ok(Ok(len)) => &buf[..len],
|
||||
Ok(Err(e)) => {continue}
|
||||
Err(_would_block) => {
|
||||
|
|
|
|||
|
|
@ -68,15 +68,15 @@ impl PeerPcb {
|
|||
let rid: i32 = random();
|
||||
log::debug!("start read loop {}", rid);
|
||||
loop{
|
||||
log::debug!("{}: waiting for packet", rid);
|
||||
// log::debug!("{}: waiting for packet", rid);
|
||||
let Some(socket) = &self.socket else {
|
||||
continue
|
||||
};
|
||||
let mut res_buf = [0;1500];
|
||||
log::debug!("{} : waiting for readability on {:?}", rid, socket);
|
||||
match timeout(Duration::from_secs(2), socket.readable()).await {
|
||||
// log::debug!("{} : waiting for readability on {:?}", rid, socket);
|
||||
match timeout(Duration::from_millis(10), socket.readable()).await {
|
||||
Err(e) => {
|
||||
log::debug!("{}: timeout waiting for readability on {:?}", rid, e);
|
||||
// log::debug!("{}: timeout waiting for readability on {:?}", rid, e);
|
||||
continue
|
||||
}
|
||||
Ok(Err(e)) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue