Changed ping logic to eliminate a rare panic under heavy load (fixes #120).

This commit is contained in:
Aaron Weiss 2018-02-23 20:54:05 +01:00
parent 2440a751d9
commit b8b1361a20
No known key found for this signature in database
GPG key ID: 047D32DF25DC22EF

View file

@ -69,12 +69,14 @@ where
}
fn send_ping(&mut self) -> error::Result<()> {
self.last_ping_sent = Instant::now();
self.last_ping_data = format!("{}", Local::now().timestamp());
let data = self.last_ping_data.clone();
let last_ping_data = format!("{}", Local::now().timestamp());
let data = last_ping_data.clone();
let result = self.start_send(Command::PING(data, None).into())?;
assert!(result.is_ready());
if let AsyncSink::Ready = result {
self.poll_complete()?;
self.last_ping_sent = Instant::now();
self.last_ping_data = last_ping_data;
}
Ok(())
}