File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -239,11 +239,13 @@ where
239239
240240 match result {
241241 Ok ( true ) | Err ( _) => {
242- let mut io = state. io . take ( ) . unwrap ( ) ;
242+ let io = state. io . take ( ) ;
243243 * self = Self :: Unbound ( state) ;
244244
245- io. close ( Close :: Both ) . await . map_err ( Error :: Io ) ?;
246- let _ = io. abort ( ) . await ;
245+ if let Some ( mut io) = io {
246+ io. close ( Close :: Both ) . await . map_err ( Error :: Io ) ?;
247+ let _ = io. abort ( ) . await ;
248+ }
247249 }
248250 _ => {
249251 * self = Self :: Unbound ( state) ;
@@ -255,6 +257,17 @@ where
255257 Ok ( ( ) )
256258 }
257259
260+ pub async fn close ( mut self ) -> Result < ( ) , Error < T :: Error > > {
261+ let res = self . complete ( ) . await ;
262+
263+ if let Some ( mut io) = self . unbind ( ) . io . take ( ) {
264+ io. close ( Close :: Both ) . await . map_err ( Error :: Io ) ?;
265+ let _ = io. abort ( ) . await ;
266+ }
267+
268+ res
269+ }
270+
258271 async fn complete_request ( & mut self ) -> Result < ( ) , Error < T :: Error > > {
259272 self . request_mut ( ) ?. io . finish ( ) . await ?;
260273
You can’t perform that action at this time.
0 commit comments