File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -141,6 +141,7 @@ pin_project! {
141141 write_waker: Option <Waker >,
142142 flush_waker: Option <Waker >,
143143 close_waker: Option <Waker >,
144+ closed: bool ,
144145 #[ pin]
145146 _p: PhantomPinned ,
146147 }
@@ -169,6 +170,7 @@ impl<S> AsyncWriteStream<S> {
169170 write_waker : None ,
170171 flush_waker : None ,
171172 close_waker : None ,
173+ closed : false ,
172174 _p : PhantomPinned ,
173175 }
174176 }
@@ -402,6 +404,9 @@ impl<S: AsyncWrite + Unpin + 'static> AsyncWriteStream<S> {
402404 }
403405
404406 fn poll_close_impl ( self : Pin < & mut Self > ) -> Poll < io:: Result < ( ) > > {
407+ if self . closed {
408+ return Poll :: Ready ( Ok ( ( ) ) ) ;
409+ }
405410 let this = self . project ( ) ;
406411 // SAFETY:
407412 // - The future won't live longer than the stream.
@@ -415,7 +420,7 @@ impl<S: AsyncWrite + Unpin + 'static> AsyncWriteStream<S> {
415420 arr. with ( |waker| {
416421 let cx = & mut Context :: from_waker ( waker) ;
417422 let res = poll_future ! ( this. shutdown_future, cx, inner. get_mut( ) . shutdown( ) ) ;
418- Poll :: Ready ( res)
423+ Poll :: Ready ( res. inspect ( |_| * this . closed = true ) )
419424 } )
420425 }
421426}
You can’t perform that action at this time.
0 commit comments