Skip to content

Commit

Permalink
Merge pull request #6 from Dounutsubtly/dev
Browse files Browse the repository at this point in the history
fix(server): improve error handling in connection acceptance loop.
  • Loading branch information
Itsusinn authored Aug 25, 2024
2 parents c9147bf + 8d4cb11 commit d7a7f67
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 d7a7f67

Please sign in to comment.