Lower timeout interval
This commit is contained in:
parent
4dd31d5f1e
commit
d012ca144c
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)) => {
|
||||
|
|
|
|||
|
|
@ -30,15 +30,12 @@ impl TunInterface {
|
|||
// #[instrument]
|
||||
pub async fn recv(&mut self, buf: &mut [u8]) -> io::Result<usize> {
|
||||
loop {
|
||||
log::debug!("TunInterface receiving...");
|
||||
// log::debug!("TunInterface receiving...");
|
||||
let mut guard = self.inner.readable_mut().await?;
|
||||
log::debug!("Got! readable_mut");
|
||||
// log::debug!("Got! readable_mut");
|
||||
match guard.try_io(|inner| {
|
||||
// log::debug!("Got! {:#?}", inner);
|
||||
let raw_ref = (*inner).get_mut();
|
||||
// log::debug!("Got mut ref! {:#?}", raw_ref);
|
||||
let recved = raw_ref.recv(buf);
|
||||
// log::debug!("Got recved! {:#?}", recved);
|
||||
recved
|
||||
}) {
|
||||
Ok(result) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue