Skip to content

Commit

Permalink
pd: cancel call when refreshing client (tikv#2669)
Browse files Browse the repository at this point in the history
* pd: cancel call when refreshing client
  • Loading branch information
BusyJay authored and ngaut committed Jan 12, 2018
1 parent d8a4f08 commit bb7dfa8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/pd/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ impl PdClient for RpcClient {
Error::Other(box_err!("failed to recv heartbeat: {:?}", e))
}).map(|r| (r, WriteFlags::default())),
)
.map(|_| ()),
.map(|(mut sender, _)| sender.get_mut().cancel()),
) as PdFuture<_>
}
None => unreachable!(),
Expand Down
2 changes: 2 additions & 0 deletions src/pd/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ impl Stream for HeartbeatReceiver {
}
}

warn!("heartbeat receiver is stale, refreshing..");
self.receiver.take();

let mut inner = self.inner.wl();
let mut receiver = None;
if let Either::Left(ref mut recv) = inner.hb_receiver {
receiver = recv.take();
info!("heartbeat receiver is refreshed.");
}
if receiver.is_some() {
self.receiver = receiver;
Expand Down

0 comments on commit bb7dfa8

Please sign in to comment.