fixed one concurrency problem in admin.Close() detected when running the

tests 100 times.
This commit is contained in:
Erik Brakkee 2024-08-24 23:35:18 +02:00
parent db094d2a13
commit 3117fff4ce
2 changed files with 4 additions and 1 deletions

View File

@ -14,7 +14,7 @@ vet: fmt
go vet ./...
test: build
go test -v -count=1 ./...
go test -count=1 ./...
build: generate vet
mkdir -p bin

View File

@ -87,6 +87,9 @@ func NewAdmin() *Admin {
}
func (admin *Admin) Close() {
admin.mutex.Lock()
defer admin.mutex.Unlock()
for _, client := range admin.clients {
client.clientConnection.Close()
client.agentConnection.Close()