fix set_timeout

This commit is contained in:
fakeshadow 2021-04-04 01:13:51 +08:00
parent 7a773bc610
commit 209291f41b
1 changed files with 6 additions and 10 deletions

View File

@ -217,8 +217,8 @@ impl Accept {
if now < inst { if now < inst {
// still timed out. try set new timeout. // still timed out. try set new timeout.
let dur = inst - now; info.timeout_deadline = Some(inst);
self.set_timeout(dur); self.set_timeout(inst - now);
} else if !self.backpressure { } else if !self.backpressure {
// timeout expired register socket again. // timeout expired register socket again.
self.register_logged(token, info); self.register_logged(token, info);
@ -234,9 +234,9 @@ impl Accept {
// update Accept timeout duration. would keep the smallest duration. // update Accept timeout duration. would keep the smallest duration.
fn set_timeout(&mut self, dur: Duration) { fn set_timeout(&mut self, dur: Duration) {
match self.timeout { match self.timeout {
Some(timeout) => { Some(ref mut timeout) => {
if timeout > dur { if *timeout > dur {
self.timeout = Some(dur); *timeout = dur;
} }
} }
None => self.timeout = Some(dur), None => self.timeout = Some(dur),
@ -274,12 +274,8 @@ impl Accept {
} }
} }
fn deregister(&self, info: &mut ServerSocketInfo) -> io::Result<()> {
self.poll.registry().deregister(&mut info.lst)
}
fn deregister_logged(&self, info: &mut ServerSocketInfo) { fn deregister_logged(&self, info: &mut ServerSocketInfo) {
match self.deregister(info) { match self.poll.registry().deregister(&mut info.lst) {
Ok(_) => info!("Paused accepting connections on {}", info.addr), Ok(_) => info!("Paused accepting connections on {}", info.addr),
Err(e) => { Err(e) => {
error!("Can not deregister server socket {}", e) error!("Can not deregister server socket {}", e)