Skip to content

Commit 9c82ea1

Browse files
ale-linuxmastersingh24
authored andcommitted
[FAB-14604] containerLocks use CCID type as map key
Change-Id: Ib4909f0424f5a3a0874d16a899a72fb5dfa2eb77 Signed-off-by: Alessandro Sorniotti <ale.linux@sopit.net>
1 parent 229c334 commit 9c82ea1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

core/container/controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type refCountedLock struct {
4545
// eventually probably need fine grained management)
4646
type VMController struct {
4747
sync.RWMutex
48-
containerLocks map[string]*refCountedLock
48+
containerLocks map[ccintf.CCID]*refCountedLock
4949
vmProviders map[string]VMProvider
5050
}
5151

@@ -54,7 +54,7 @@ var vmLogger = flogging.MustGetLogger("container")
5454
// NewVMController creates a new instance of VMController
5555
func NewVMController(vmProviders map[string]VMProvider) *VMController {
5656
return &VMController{
57-
containerLocks: make(map[string]*refCountedLock),
57+
containerLocks: make(map[ccintf.CCID]*refCountedLock),
5858
vmProviders: vmProviders,
5959
}
6060
}
@@ -67,7 +67,7 @@ func (vmc *VMController) newVM(typ string) VM {
6767
return v.NewVM()
6868
}
6969

70-
func (vmc *VMController) lockContainer(id string) {
70+
func (vmc *VMController) lockContainer(id ccintf.CCID) {
7171
//get the container lock under global lock
7272
vmc.Lock()
7373
var refLck *refCountedLock
@@ -85,7 +85,7 @@ func (vmc *VMController) lockContainer(id string) {
8585
vmLogger.Debugf("got container (%s) lock", id)
8686
}
8787

88-
func (vmc *VMController) unlockContainer(id string) {
88+
func (vmc *VMController) unlockContainer(id ccintf.CCID) {
8989
vmc.Lock()
9090
if refLck, ok := vmc.containerLocks[id]; ok {
9191
if refLck.refCount <= 0 {
@@ -202,8 +202,8 @@ func (vmc *VMController) Process(vmtype string, req VMCReq) error {
202202
v := vmc.newVM(vmtype)
203203
ccid := req.GetCCID()
204204

205-
vmc.lockContainer(string(ccid))
206-
defer vmc.unlockContainer(string(ccid))
205+
vmc.lockContainer(ccid)
206+
defer vmc.unlockContainer(ccid)
207207
return req.Do(v)
208208
}
209209

0 commit comments

Comments
 (0)