fix: multiple bugfixes
- Fix data race: use atomic.Bool for running in server.go - Fix busy loop in timer.go: use time.After when idle - Fix division by zero in print_replay - Fix silently swallowed errors in proto_generator - Fix suppressed error in native_encoder - Delete unused registry_data_hunter
This commit is contained in:
+5
-3
@@ -3,6 +3,7 @@ package server
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/admin-else/strom/mc/proto"
|
||||
"github.com/admin-else/strom/mc/proto_base"
|
||||
@@ -68,8 +69,9 @@ func StartServerWithOnConn(listenAddr string, onConn func(c *proto.Conn) (err er
|
||||
return
|
||||
}
|
||||
defer l.Close()
|
||||
running := true
|
||||
for running {
|
||||
running := atomic.Bool{}
|
||||
running.Store(true)
|
||||
for running.Load() {
|
||||
var cNet net.Conn
|
||||
cNet, err = l.Accept()
|
||||
if err != nil {
|
||||
@@ -80,7 +82,7 @@ func StartServerWithOnConn(listenAddr string, onConn func(c *proto.Conn) (err er
|
||||
defer c.Close()
|
||||
connErr := onConn(c)
|
||||
if errors.Is(connErr, ShutDownServerErr) {
|
||||
running = false
|
||||
running.Store(false)
|
||||
}
|
||||
c.Log.Error("closing connection", "err", connErr)
|
||||
if connErr != nil {
|
||||
|
||||
Reference in New Issue
Block a user