Fix atomicity violation in network-devp2p (#11277)
This commit is contained in:
parent
4c6b282bee
commit
f1f64930cf
@ -220,14 +220,13 @@ impl Connection {
|
||||
|
||||
/// Register this connection with the IO event loop.
|
||||
pub fn register_socket<Host: Handler>(&self, reg: Token, event_loop: &mut EventLoop<Host>) -> io::Result<()> {
|
||||
if self.registered.load(AtomicOrdering::SeqCst) {
|
||||
if self.registered.compare_and_swap(false, true, AtomicOrdering::SeqCst) {
|
||||
return Ok(());
|
||||
}
|
||||
trace!(target: "network", "connection register; token={:?}", reg);
|
||||
if let Err(e) = event_loop.register(&self.socket, reg, self.interest, PollOpt::edge() /* | PollOpt::oneshot() */) { // TODO: oneshot is broken on windows
|
||||
trace!(target: "network", "Failed to register {:?}, {:?}", reg, e);
|
||||
}
|
||||
self.registered.store(true, AtomicOrdering::SeqCst);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user