Poll timeout calculation fix.

This commit is contained in:
Egor Karavaev
2017-11-13 20:05:09 +03:00
parent 337f318f6f
commit 2242ad90f9
2 changed files with 13 additions and 12 deletions
+8 -7
View File
@@ -176,18 +176,19 @@ impl Smolnetd {
error!("poll error: {}", err);
break 0;
}
Ok(None) => {
break ::std::u64::MAX;
}
Ok(Some(n)) if n > 0 => {
break n;
}
Ok(wait_till) if self.input_queue.borrow().is_empty() => match wait_till {
None => break ::std::i64::MAX,
Some(n) if n > timestamp => {
break ::std::cmp::min(::std::i64::MAX as u64, n - timestamp) as i64
}
_ => {}
},
_ => {}
}
};
self.notify_sockets()?;
Ok(::std::cmp::min(
::std::cmp::max(Smolnetd::MIN_CHECK_TIMEOUT_MS, timeout as i64),
::std::cmp::max(Smolnetd::MIN_CHECK_TIMEOUT_MS, timeout),
Smolnetd::MAX_CHECK_TIMEOUT_MS,
))
}