distributing listening jobs to separated tasks
This commit is contained in:
parent
ba014f2895
commit
662491fc58
@ -68,14 +68,14 @@ impl Connection {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let res = tokio::select! {
|
let res = tokio::select! {
|
||||||
res = Self::listen_uni_streams(conn.clone(), uni_streams) => res,
|
res = tokio::spawn(Self::listen_uni_streams(conn.clone(), uni_streams)) => res,
|
||||||
res = Self::listen_bi_streams(conn.clone(), bi_streams) => res,
|
res = tokio::spawn(Self::listen_bi_streams(conn.clone(), bi_streams)) => res,
|
||||||
res = Self::listen_datagrams(conn.clone(), datagrams) => res,
|
res = tokio::spawn(Self::listen_datagrams(conn.clone(), datagrams)) => res,
|
||||||
res = Self::listen_received_udp_packet(conn.clone(), recv_pkt_rx) => res,
|
res = tokio::spawn(Self::listen_received_udp_packet(conn.clone(), recv_pkt_rx)) => res,
|
||||||
Err(err) = Self::handle_authentication_timeout(conn, auth_timeout) => Err(err),
|
Err(err) = Self::handle_authentication_timeout(conn, auth_timeout) => Ok(Err(err)),
|
||||||
};
|
};
|
||||||
|
|
||||||
match res {
|
match res.unwrap() {
|
||||||
Ok(()) => unreachable!(),
|
Ok(()) => unreachable!(),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
is_closed.set_closed();
|
is_closed.set_closed();
|
||||||
|
@ -136,12 +136,10 @@ impl UdpSession {
|
|||||||
let (send_pkt_tx, send_pkt_rx) = mpsc::channel(1);
|
let (send_pkt_tx, send_pkt_rx) = mpsc::channel(1);
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let res = tokio::select! {
|
match tokio::select! {
|
||||||
res = tokio::spawn(Self::listen_send_packet(socket.clone(), send_pkt_rx)) => res,
|
res = Self::listen_send_packet(socket.clone(), send_pkt_rx) => res,
|
||||||
res = tokio::spawn(Self::listen_receive_packet(socket, assoc_id, recv_pkt_tx, max_pkt_size)) => res,
|
res = Self::listen_receive_packet(socket, assoc_id, recv_pkt_tx, max_pkt_size) => res,
|
||||||
};
|
} {
|
||||||
|
|
||||||
match res.unwrap() {
|
|
||||||
Ok(()) => (),
|
Ok(()) => (),
|
||||||
Err(err) => log::warn!("[{src_addr}] [udp-session] [{assoc_id}] {err}"),
|
Err(err) => log::warn!("[{src_addr}] [udp-session] [{assoc_id}] {err}"),
|
||||||
}
|
}
|
||||||
|
@ -51,11 +51,9 @@ impl Server {
|
|||||||
log::info!("Server started. Listening: {}", self.listen_addr);
|
log::info!("Server started. Listening: {}", self.listen_addr);
|
||||||
|
|
||||||
while let Some(conn) = self.incoming.next().await {
|
while let Some(conn) = self.incoming.next().await {
|
||||||
let token = self.token.clone();
|
|
||||||
|
|
||||||
tokio::spawn(Connection::handle(
|
tokio::spawn(Connection::handle(
|
||||||
conn,
|
conn,
|
||||||
token,
|
self.token.clone(),
|
||||||
self.authentication_timeout,
|
self.authentication_timeout,
|
||||||
self.max_pkt_size,
|
self.max_pkt_size,
|
||||||
));
|
));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user