Skip to content

Commit 1be7013

Browse files
committed
Fix unordered rewrite of active-services property, so that statuses of all services are written the last
Signed-off-by: Anton Litvinov <[email protected]>
1 parent adb6758 commit 1be7013

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tequilapi/endpoints/service.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"net/http"
2424
"strconv"
2525
"strings"
26+
"sync"
2627

2728
"github.com/gin-gonic/gin"
2829
"github.com/mysteriumnetwork/go-rest/apierror"
@@ -43,6 +44,7 @@ type ServiceEndpoint struct {
4344
optionsParser map[string]services.ServiceOptionsParser
4445
proposalRepository proposalRepository
4546
tequilaApiClient *tequilapi_client.Client
47+
activeServicesMu sync.Mutex
4648
}
4749

4850
var (
@@ -249,6 +251,10 @@ func (se *ServiceEndpoint) ServiceStop(c *gin.Context) {
249251
}
250252

251253
func (se *ServiceEndpoint) updateActiveServicesInUserConfig() {
254+
// restrict concurrent update of ActiveServices property, so that statuses of all services are written the last
255+
se.activeServicesMu.Lock()
256+
defer se.activeServicesMu.Unlock()
257+
252258
runningInstances := se.serviceManager.List(false)
253259
activeServices := make([]string, len(runningInstances))
254260
for i, service := range runningInstances {

0 commit comments

Comments
 (0)