Skip to content

Commit

Permalink
fix(server): improve error handling in connection acceptance loop.
Browse files Browse the repository at this point in the history
- Add proper error logging for connection acceptance failures
  • Loading branch information
waaa authored and waaa committed Aug 25, 2024
1 parent c9147bf commit 8d4cb11
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions tuic-server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,24 +146,30 @@ impl Server {
);

loop {
let Some(conn) = self.ep.accept().await else {
return;
};
let Ok(conn) = conn.accept() else {
return;
};

tokio::spawn(Connection::handle(
conn,
self.users.clone(),
self.udp_relay_ipv6,
self.zero_rtt_handshake,
self.auth_timeout,
self.task_negotiation_timeout,
self.max_external_pkt_size,
self.gc_interval,
self.gc_lifetime,
));
match self.ep.accept().await {
Some(conn) => match conn.accept() {
Ok(conn) => {
tokio::spawn(Connection::handle(
conn,
self.users.clone(),
self.udp_relay_ipv6,
self.zero_rtt_handshake,
self.auth_timeout,
self.task_negotiation_timeout,
self.max_external_pkt_size,
self.gc_interval,
self.gc_lifetime,
));
}
Err(e) => {
log::debug!("[Incoming] Failed to accept connection: {e}");
}
},
None => {
log::debug!("[Incoming] ep.accept() returned None.");
return;
}
}
}
}
}

0 comments on commit 8d4cb11

Please sign in to comment.