Skip to content

Commit

Permalink
Merge pull request #1847 from mrpalide/fix/solve-datarace-in-hv
Browse files Browse the repository at this point in the history
fix datarace in hv
  • Loading branch information
mrpalide authored Jun 29, 2024
2 parents ac718fb + 8a73030 commit e1726a8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/visor/hypervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type Hypervisor struct {
dmsgC *dmsg.Client
users *usermanager.UserManager
mu *sync.RWMutex
vsMu *sync.RWMutex
selfConn Conn
logger *logging.Logger
}
Expand Down Expand Up @@ -95,6 +96,7 @@ func NewHypervisor(config visorconfig.HypervisorConfig, visor *Visor, dmsgC *dms
dmsgC: dmsgC,
users: usermanager.NewUserManager(mLogger, singleUserDB, config.Cookies),
mu: new(sync.RWMutex),
vsMu: new(sync.RWMutex),
selfConn: selfConn,
logger: mLogger.PackageLogger("hypervisor"),
}
Expand Down Expand Up @@ -562,7 +564,9 @@ func (hv *Hypervisor) getAllVisorsSummary() http.HandlerFunc {
} else {
log.Trace("Obtained summary via RPC.")
resp := makeSummaryResp(err == nil, false, summary)
hv.vsMu.Lock()
summaries = append(summaries, resp)
hv.vsMu.Unlock()
}
wg.Done()
}(pk, c)
Expand Down

0 comments on commit e1726a8

Please sign in to comment.