Add more error handling and mutex guards

This commit is contained in:
Pijus Kamandulis
2025-01-27 21:09:37 +02:00
parent d6b816b55a
commit 125f10d8a2
8 changed files with 62 additions and 26 deletions

View File

@@ -14,7 +14,7 @@ type ServerInstance struct {
}
var serverInstances map[string]*ServerInstance
var mutex sync.RWMutex
var mutex sync.Mutex
const (
ResponseSuccess = 0
@@ -32,8 +32,8 @@ const (
)
func getInstance(serverName string) (*ServerInstance, bool) {
mutex.RLock()
defer mutex.RUnlock()
mutex.Lock()
defer mutex.Unlock()
if serverInstances == nil {
serverInstances = make(map[string]*ServerInstance)