mirror of
https://github.com/CPunch/gopenfusion.git
synced 2024-11-25 00:21:05 +00:00
this should be CompareAndSwap oopsd D:
This commit is contained in:
parent
1f66acfd25
commit
3abba0ca3c
@ -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}
|
||||||
|
Loading…
Reference in New Issue
Block a user