feat: only for download peer spawn a thread
This commit is contained in:
+18
-10
@@ -228,15 +228,23 @@ 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(
|
|
||||||
peer,
|
ConnectionType::F => {
|
||||||
stream,
|
thread::spawn(move || {
|
||||||
reader,
|
trace!(
|
||||||
init_data.token,
|
"[listener:{peer_ip}:{peer_port}] handling file connection in thread"
|
||||||
&context,
|
);
|
||||||
&peer_ip,
|
handle_file_connection(
|
||||||
peer_port,
|
peer,
|
||||||
),
|
stream,
|
||||||
|
reader,
|
||||||
|
init_data.token,
|
||||||
|
&context,
|
||||||
|
&peer_ip,
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user