From 3abba0ca3cd4122d4e55f861eeb0bb9f506c90ab Mon Sep 17 00:00:00 2001 From: CPunch Date: Mon, 27 Nov 2023 21:34:39 -0600 Subject: [PATCH] this should be CompareAndSwap oopsd D: --- internal/protocol/cnpeer.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/protocol/cnpeer.go b/internal/protocol/cnpeer.go index 9013567..8186993 100644 --- a/internal/protocol/cnpeer.go +++ b/internal/protocol/cnpeer.go @@ -98,10 +98,9 @@ func (peer *CNPeer) SetActiveKey(whichKey int) { func (peer *CNPeer) Kill() { log.Printf("Killing peer %p", peer) - if !peer.alive.Load() { + if !peer.alive.CompareAndSwap(true, false) { return } - peer.alive.Store(false) peer.conn.Close() peer.eRecv <- &Event{Type: EVENT_CLIENT_DISCONNECT, Peer: peer}