@@ -418,23 +418,25 @@ impl Server {
418418 let listener = self . listener ( & enclave_addr)
419419 . ok_or ( IoError :: new ( IoErrorKind :: InvalidInput , "Information about provided file descriptor was not found" ) ) ?;
420420 let listener = listener. lock ( ) . unwrap ( ) ;
421- match listener. listener . accept ( ) {
422- Ok ( ( conn, peer) ) => {
423- let vsock = Vsock :: new :: < Std > ( ) ?;
424- let runner_addr = vsock. addr :: < Std > ( ) ?;
425- client_conn. send ( & Response :: IncomingConnection {
426- local : conn. local_addr ( ) ?. into ( ) ,
427- peer : peer. into ( ) ,
428- proxy_port : runner_addr. port ( ) ,
429- } ) ?;
430-
431- //TODO what to do with these errors?
432- let proxy = vsock. connect_with_cid_port ( enclave_addr. cid ( ) , enclave_addr. port ( ) ) . unwrap ( ) ;
433- self . add_connection ( proxy, conn, "remote" . to_string ( ) ) ?;
434- Ok ( ( ) )
435- } ,
436- Err ( e) => Err ( e. into ( ) ) ,
421+ let ( conn, peer) = listener. listener . accept ( ) ?;
422+ let vsock = Vsock :: new :: < Std > ( ) ?;
423+ let runner_addr = vsock. addr :: < Std > ( ) ?;
424+ client_conn. send ( & Response :: IncomingConnection {
425+ local : conn. local_addr ( ) ?. into ( ) ,
426+ peer : peer. into ( ) ,
427+ proxy_port : runner_addr. port ( ) ,
428+ } ) ?;
429+
430+ let connect = || -> Result < ( ) , VmeError > {
431+ // Connect to enclave at the expected port
432+ let proxy = vsock. connect_with_cid_port ( enclave_addr. cid ( ) , enclave_addr. port ( ) ) ?;
433+ self . add_connection ( proxy, conn, "remote" . to_string ( ) ) ?;
434+ Ok ( ( ) )
435+ } ;
436+ if let Err ( e) = connect ( ) {
437+ println ! ( "[error] Failed to connect to the enclave after it requested an accept: {:?}" , e) ;
437438 }
439+ Ok ( ( ) )
438440 }
439441
440442 fn handle_request_close ( self : Arc < Self > , enclave_port : u32 , conn : & mut ClientConnection ) -> Result < ( ) , VmeError > {
@@ -511,7 +513,6 @@ impl Server {
511513 . spawn ( move || {
512514 let mut conn = ClientConnection :: new ( stream. unwrap ( ) ) ;
513515 if let Err ( e) = server. handle_client ( & mut conn) {
514- // TODO handle error
515516 let _ = conn. send ( & Response :: Failed ( e) ) ;
516517 }
517518 } ) ;
0 commit comments