From a4c9aaf337459d77edbf58df36ad4ad75b1d1746 Mon Sep 17 00:00:00 2001 From: fakeshadow <24548779@qq.com> Date: Fri, 8 Jan 2021 04:42:09 +0800 Subject: [PATCH] fix extra branch in h1 dispatcher timer (#1882) --- actix-http/src/h1/dispatcher.rs | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/actix-http/src/h1/dispatcher.rs b/actix-http/src/h1/dispatcher.rs index a914880ce..8ef96fbef 100644 --- a/actix-http/src/h1/dispatcher.rs +++ b/actix-http/src/h1/dispatcher.rs @@ -687,15 +687,11 @@ where if let Some(deadline) = this.codec.config().client_disconnect_timer() { - if let Some(timer) = this.ka_timer.as_mut().as_pin_mut() + if let Some(mut timer) = + this.ka_timer.as_mut().as_pin_mut() { - timer.reset(deadline); - let _ = this - .ka_timer - .as_mut() - .as_pin_mut() - .unwrap() - .poll(cx); + timer.as_mut().reset(deadline); + let _ = timer.poll(cx); } } else { // no shutdown timeout, drop socket @@ -720,15 +716,14 @@ where } else if let Some(deadline) = this.codec.config().keep_alive_expire() { - if let Some(timer) = this.ka_timer.as_mut().as_pin_mut() { - timer.reset(deadline); - let _ = - this.ka_timer.as_mut().as_pin_mut().unwrap().poll(cx); + if let Some(mut timer) = this.ka_timer.as_mut().as_pin_mut() { + timer.as_mut().reset(deadline); + let _ = timer.poll(cx); } } - } else if let Some(timer) = this.ka_timer.as_mut().as_pin_mut() { - timer.reset(*this.ka_expire); - let _ = this.ka_timer.as_mut().as_pin_mut().unwrap().poll(cx); + } else if let Some(mut timer) = this.ka_timer.as_mut().as_pin_mut() { + timer.as_mut().reset(*this.ka_expire); + let _ = timer.poll(cx); } } Poll::Pending => {}