this should be CompareAndSwap oopsd D:

This commit is contained in:
CPunch 2023-11-27 21:34:39 -06:00
parent 1f66acfd25
commit 3abba0ca3c

View File

@ -98,10 +98,9 @@ func (peer *CNPeer) SetActiveKey(whichKey int) {
func (peer *CNPeer) Kill() { func (peer *CNPeer) Kill() {
log.Printf("Killing peer %p", peer) log.Printf("Killing peer %p", peer)
if !peer.alive.Load() { if !peer.alive.CompareAndSwap(true, false) {
return return
} }
peer.alive.Store(false)
peer.conn.Close() peer.conn.Close()
peer.eRecv <- &Event{Type: EVENT_CLIENT_DISCONNECT, Peer: peer} peer.eRecv <- &Event{Type: EVENT_CLIENT_DISCONNECT, Peer: peer}