File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,16 @@ static ALIVE: AtomicBool = AtomicBool::new(true);
4545/// a count of connected clients
4646static CLIENTS : AtomicU16 = AtomicU16 :: new ( 0 ) ;
4747
48+ fn tcp_stream_try_clone ( stream : & TcpStream ) -> BoxResult < TcpStream > {
49+ use std:: os:: fd:: { AsRawFd , BorrowedFd } ;
50+ let fd = unsafe { BorrowedFd :: borrow_raw ( stream. as_raw_fd ( ) ) } ;
51+ let fd = fd. try_clone_to_owned ( ) ?;
52+ let socket: socket2:: Socket = socket2:: Socket :: from ( fd) ;
53+ let stream: std:: net:: TcpStream = socket. into ( ) ;
54+ let socket = TcpStream :: from_std ( stream) ;
55+ Ok ( socket)
56+ }
57+
4858fn handle_client (
4959 stream : & mut TcpStream ,
5060 cpu_affinity_manager : Arc < Mutex < crate :: utils:: cpu_affinity:: CpuAffinityManager > > ,
@@ -64,7 +74,7 @@ fn handle_client(
6474 ) = channel ( ) ;
6575
6676 //a closure used to pass results from stream-handlers to the client-communication stream
67- let mut forwarding_send_stream = stream . try_clone ( ) ?;
77+ let mut forwarding_send_stream = tcp_stream_try_clone ( stream ) ?;
6878 let mut results_handler = || -> BoxResult < ( ) > {
6979 // drain all results every time this closer is invoked
7080 while let Ok ( result) = results_rx. try_recv ( ) {
You can’t perform that action at this time.
0 commit comments