@@ -90,7 +90,6 @@ use wasmtime_wasi::OutputStream;
9090use wasmtime_wasi:: {
9191 async_trait,
9292 bindings:: io:: {
93- error:: Error as HostError ,
9493 poll:: Pollable as HostPollable ,
9594 streams:: { InputStream as BoxInputStream , OutputStream as BoxOutputStream } ,
9695 } ,
@@ -297,17 +296,8 @@ pub struct ClientConnection {
297296}
298297
299298impl < ' a > generated:: types:: HostClientConnection for WasiTlsCtx < ' a > {
300- fn close_notify (
301- & mut self ,
302- this : Resource < ClientConnection > ,
303- ) -> wasmtime:: Result < Option < Result < ( ) , wasmtime:: component:: Resource < HostError > > > > {
304- let result = self . table . get_mut ( & this) ?. writer . close_notify ( ) ;
305-
306- Ok ( match result {
307- None => None ,
308- Some ( Ok ( ( ) ) ) => Some ( Ok ( ( ) ) ) ,
309- Some ( Err ( e) ) => Some ( Err ( self . table . push ( anyhow:: Error :: new ( e) ) ?) ) ,
310- } )
299+ fn close_output ( & mut self , this : Resource < ClientConnection > ) -> wasmtime:: Result < ( ) > {
300+ self . table . get_mut ( & this) ?. writer . close ( )
311301 }
312302
313303 fn drop ( & mut self , this : Resource < ClientConnection > ) -> wasmtime:: Result < ( ) > {
@@ -524,14 +514,13 @@ impl TlsWriter {
524514 }
525515 }
526516
527- fn close_notify ( & mut self ) -> Option < Result < ( ) , io :: Error > > {
517+ fn close ( & mut self ) {
528518 match std:: mem:: replace ( & mut self . state , WriteState :: Closed ) {
529519 // No write in progress, immediately shut down:
530520 WriteState :: Ready ( mut stream) => {
531521 self . state = WriteState :: Closing ( wasmtime_wasi:: runtime:: spawn ( async move {
532522 stream. shutdown ( ) . await
533523 } ) ) ;
534- None
535524 }
536525
537526 // Schedule the shutdown after the current write has finished:
@@ -540,15 +529,12 @@ impl TlsWriter {
540529 let mut stream = write. await ?;
541530 stream. shutdown ( ) . await
542531 } ) ) ;
543- None
544532 }
545533
546534 WriteState :: Closing ( t) => {
547535 self . state = WriteState :: Closing ( t) ;
548- None
549536 }
550- WriteState :: Closed => Some ( Ok ( ( ) ) ) ,
551- WriteState :: Error ( e) => Some ( Err ( e. into ( ) ) ) ,
537+ WriteState :: Closed | WriteState :: Error ( _) => { }
552538 }
553539 }
554540
@@ -587,17 +573,9 @@ impl AsyncTlsWriteStream {
587573 AsyncTlsWriteStream ( Arc :: new ( Mutex :: new ( writer) ) )
588574 }
589575
590- fn close_notify ( & mut self ) -> Option < Result < ( ) , StreamError > > {
591- let mut writer = match try_lock_for_stream ( & self . 0 ) {
592- Ok ( writer) => writer,
593- Err ( err) => return Some ( Err ( err) ) ,
594- } ;
595-
596- match writer. close_notify ( ) {
597- None => None ,
598- Some ( Ok ( ( ) ) ) => Some ( Ok ( ( ) ) ) ,
599- Some ( Err ( e) ) => Some ( Err ( StreamError :: LastOperationFailed ( e. into ( ) ) ) ) ,
600- }
576+ fn close ( & mut self ) -> wasmtime:: Result < ( ) > {
577+ try_lock_for_stream ( & self . 0 ) ?. close ( ) ;
578+ Ok ( ( ) )
601579 }
602580}
603581
0 commit comments