ensure write lock isn't held when calling handlers (#4285)
This commit is contained in:
parent
73b67da3cf
commit
b739704902
@ -613,11 +613,17 @@ impl LightProtocol {
|
|||||||
trace!(target: "les", "Peer {} disconnecting", peer);
|
trace!(target: "les", "Peer {} disconnecting", peer);
|
||||||
|
|
||||||
self.pending_peers.write().remove(&peer);
|
self.pending_peers.write().remove(&peer);
|
||||||
if let Some(peer_info) = self.peers.write().remove(&peer) {
|
let unfulfilled = match self.peers.write().remove(&peer) {
|
||||||
|
None => return,
|
||||||
|
Some(peer_info) => {
|
||||||
let peer_info = peer_info.into_inner();
|
let peer_info = peer_info.into_inner();
|
||||||
let mut unfulfilled: Vec<_> = peer_info.pending_requests.collect_ids();
|
let mut unfulfilled: Vec<_> = peer_info.pending_requests.collect_ids();
|
||||||
unfulfilled.extend(peer_info.failed_requests);
|
unfulfilled.extend(peer_info.failed_requests);
|
||||||
|
|
||||||
|
unfulfilled
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
for handler in &self.handlers {
|
for handler in &self.handlers {
|
||||||
handler.on_disconnect(&Ctx {
|
handler.on_disconnect(&Ctx {
|
||||||
peer: peer,
|
peer: peer,
|
||||||
@ -626,7 +632,6 @@ impl LightProtocol {
|
|||||||
}, &unfulfilled)
|
}, &unfulfilled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Execute the given closure with a basic context derived from the I/O context.
|
/// Execute the given closure with a basic context derived from the I/O context.
|
||||||
pub fn with_context<F, T>(&self, io: &IoContext, f: F) -> T
|
pub fn with_context<F, T>(&self, io: &IoContext, f: F) -> T
|
||||||
|
Loading…
Reference in New Issue
Block a user