feat: only for download peer spawn a thread

This commit is contained in:
Michel de Graaf
2025-11-11 14:53:40 +01:00
parent 71547aeb85
commit 1ee5755ed1
+11 -3
View File
@@ -228,7 +228,13 @@ fn handle_incoming_connection(stream: TcpStream, context: ConnectionContext) {
ConnectionType::P => handle_peer_connection( ConnectionType::P => handle_peer_connection(
peer, stream, reader, &context, &peer_ip, peer_port, peer, stream, reader, &context, &peer_ip, peer_port,
), ),
ConnectionType::F => handle_file_connection(
ConnectionType::F => {
thread::spawn(move || {
trace!(
"[listener:{peer_ip}:{peer_port}] handling file connection in thread"
);
handle_file_connection(
peer, peer,
stream, stream,
reader, reader,
@@ -236,7 +242,9 @@ fn handle_incoming_connection(stream: TcpStream, context: ConnectionContext) {
&context, &context,
&peer_ip, &peer_ip,
peer_port, peer_port,
), )
});
}
ConnectionType::D => { ConnectionType::D => {
debug!("[listener:{peer_ip}:{peer_port}] connection type is D, not supported yet, closing connection. "); debug!("[listener:{peer_ip}:{peer_port}] connection type is D, not supported yet, closing connection. ");
} }
@@ -273,7 +281,7 @@ impl Listen {
}; };
let context = context.clone(); let context = context.clone();
thread::spawn(move || handle_incoming_connection(stream, context)); handle_incoming_connection(stream, context);
} }
} }
} }