mirror of
https://github.com/WiiLink24/wfc-server.git
synced 2026-03-21 17:44:58 -05:00
Change natneg inShutdown to nhttp.AtomicBool
This commit is contained in:
parent
54ff9e8a52
commit
cd530ca913
|
|
@ -11,6 +11,7 @@ import (
|
|||
"time"
|
||||
"wwfc/common"
|
||||
"wwfc/logging"
|
||||
"wwfc/nhttp"
|
||||
|
||||
"github.com/logrusorgru/aurora/v3"
|
||||
)
|
||||
|
|
@ -82,7 +83,7 @@ var (
|
|||
mutex = sync.RWMutex{}
|
||||
natnegConn net.PacketConn
|
||||
|
||||
inShutdown = false
|
||||
inShutdown nhttp.AtomicBool
|
||||
waitGroup = sync.WaitGroup{}
|
||||
)
|
||||
|
||||
|
|
@ -97,7 +98,7 @@ func StartServer(reload bool) {
|
|||
}
|
||||
|
||||
natnegConn = conn
|
||||
inShutdown = false
|
||||
inShutdown.SetFalse()
|
||||
|
||||
if reload {
|
||||
// Load state
|
||||
|
|
@ -135,7 +136,7 @@ func StartServer(reload bool) {
|
|||
logging.Notice("NATNEG", "Listening on", aurora.BrightCyan(address))
|
||||
|
||||
for {
|
||||
if inShutdown {
|
||||
if inShutdown.IsSet() {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -153,7 +154,7 @@ func StartServer(reload bool) {
|
|||
}
|
||||
|
||||
func Shutdown() {
|
||||
inShutdown = true
|
||||
inShutdown.SetTrue()
|
||||
natnegConn.Close()
|
||||
waitGroup.Wait()
|
||||
|
||||
|
|
@ -295,7 +296,7 @@ func handleConnection(conn net.PacketConn, addr net.Addr, buffer []byte) {
|
|||
|
||||
func closeSession(moduleName string, session *NATNEGSession) {
|
||||
mutex.Lock()
|
||||
if inShutdown {
|
||||
if inShutdown.IsSet() {
|
||||
mutex.Unlock()
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user