Skip to content

Commit

Permalink
Fix unordered rewrite of active-services property, so that statuses o…
Browse files Browse the repository at this point in the history
…f all services are written the last

Signed-off-by: Anton Litvinov <[email protected]>
  • Loading branch information
Zensey committed Jul 24, 2024
1 parent adb6758 commit 1be7013
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tequilapi/endpoints/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"net/http"
"strconv"
"strings"
"sync"

"github.com/gin-gonic/gin"
"github.com/mysteriumnetwork/go-rest/apierror"
Expand All @@ -43,6 +44,7 @@ type ServiceEndpoint struct {
optionsParser map[string]services.ServiceOptionsParser
proposalRepository proposalRepository
tequilaApiClient *tequilapi_client.Client
activeServicesMu sync.Mutex
}

var (
Expand Down Expand Up @@ -249,6 +251,10 @@ func (se *ServiceEndpoint) ServiceStop(c *gin.Context) {
}

func (se *ServiceEndpoint) updateActiveServicesInUserConfig() {
// restrict concurrent update of ActiveServices property, so that statuses of all services are written the last
se.activeServicesMu.Lock()
defer se.activeServicesMu.Unlock()

runningInstances := se.serviceManager.List(false)
activeServices := make([]string, len(runningInstances))
for i, service := range runningInstances {
Expand Down

0 comments on commit 1be7013

Please sign in to comment.