@@ -444,7 +444,7 @@ impl ImageProxy {
444444 } ;
445445
446446 // Verify semantic version
447- let ( protover, _ ) : ( String , ( ) ) = r. impl_request ( "Initialize" , [ ( ) ; 0 ] ) . await ?;
447+ let protover: String = r. impl_request_nofds ( "Initialize" , [ ( ) ; 0 ] ) . await ?;
448448 tracing:: debug!( "Remote protocol version: {protover}" ) ;
449449 let protover = semver:: Version :: parse ( protover. as_str ( ) ) ?;
450450 // Previously we had a feature to opt-in to requiring newer versions using `if cfg!()`.
@@ -460,6 +460,7 @@ impl ImageProxy {
460460 Ok ( r)
461461 }
462462
463+ /// Create and send a request. Should only be used by impl_request.
463464 async fn impl_request_raw < T : serde:: de:: DeserializeOwned + Send + ' static , F : FromReplyFds > (
464465 sockfd : Arc < Mutex < OwnedFd > > ,
465466 req : Request ,
@@ -509,6 +510,8 @@ impl ImageProxy {
509510 Ok ( r)
510511 }
511512
513+ /// Create a request that may return file descriptors, and also check for an unexpected
514+ /// termination of the child process.
512515 #[ instrument( skip( args) ) ]
513516 async fn impl_request < T : serde:: de:: DeserializeOwned + Send + ' static , F : FromReplyFds > (
514517 & self ,
@@ -527,6 +530,16 @@ impl ImageProxy {
527530 }
528531 }
529532
533+ /// A synchronous invocation which does not return any file descriptors.
534+ async fn impl_request_nofds < T : serde:: de:: DeserializeOwned + Send + ' static > (
535+ & self ,
536+ method : & str ,
537+ args : impl IntoIterator < Item = impl Into < serde_json:: Value > > ,
538+ ) -> Result < T > {
539+ let ( r, ( ) ) = self . impl_request ( method, args) . await ?;
540+ Ok ( r)
541+ }
542+
530543 #[ instrument]
531544 async fn finish_pipe ( & self , pipeid : PipeId ) -> Result < ( ) > {
532545 tracing:: debug!( "closing pipe" ) ;
@@ -537,14 +550,16 @@ impl ImageProxy {
537550 #[ instrument]
538551 pub async fn open_image ( & self , imgref : & str ) -> Result < OpenedImage > {
539552 tracing:: debug!( "opening image" ) ;
540- let ( imgid, ( ) ) = self . impl_request ( "OpenImage" , [ imgref] ) . await ?;
553+ let imgid = self . impl_request_nofds ( "OpenImage" , [ imgref] ) . await ?;
541554 Ok ( OpenedImage ( imgid) )
542555 }
543556
544557 #[ instrument]
545558 pub async fn open_image_optional ( & self , imgref : & str ) -> Result < Option < OpenedImage > > {
546559 tracing:: debug!( "opening image" ) ;
547- let ( imgid, ( ) ) = self . impl_request ( "OpenImageOptional" , [ imgref] ) . await ?;
560+ let imgid = self
561+ . impl_request_nofds ( "OpenImageOptional" , [ imgref] )
562+ . await ?;
548563 if imgid == 0 {
549564 Ok ( None )
550565 } else {
@@ -554,9 +569,7 @@ impl ImageProxy {
554569
555570 #[ instrument]
556571 pub async fn close_image ( & self , img : & OpenedImage ) -> Result < ( ) > {
557- tracing:: debug!( "closing image" ) ;
558- let ( r, ( ) ) = self . impl_request ( "CloseImage" , [ img. 0 ] ) . await ?;
559- Ok ( r)
572+ self . impl_request_nofds ( "CloseImage" , [ img. 0 ] ) . await
560573 }
561574
562575 async fn read_finish_pipe ( & self , pipe : FinishPipe ) -> Result < Vec < u8 > > {
@@ -714,7 +727,7 @@ impl ImageProxy {
714727 if !layer_info_proto_version ( ) . matches ( & self . protover ) {
715728 return Ok ( None ) ;
716729 }
717- let ( layers, ( ) ) = self . impl_request ( "GetLayerInfo" , [ img. 0 ] ) . await ?;
730+ let layers = self . impl_request_nofds ( "GetLayerInfo" , [ img. 0 ] ) . await ?;
718731 Ok ( Some ( layers) )
719732 }
720733
0 commit comments