Skip to content

Commit 2f095f0

Browse files
authored
Merge pull request #335 from pgporada/fix-race-condition
Fix race condition in nextVmId
2 parents 0f07388 + f97264a commit 2f095f0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

proxmox/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ func getClient(pm_api_url string, pm_user string, pm_password string, pm_otp str
168168

169169
func nextVmId(pconf *providerConfiguration) (nextId int, err error) {
170170
pconf.Mutex.Lock()
171+
defer pconf.Mutex.Unlock()
171172
pconf.MaxVMID, err = pconf.Client.GetNextID(pconf.MaxVMID + 1)
172173
if err != nil {
173174
return 0, err
174175
}
175176
nextId = pconf.MaxVMID
176-
pconf.Mutex.Unlock()
177177
return nextId, nil
178178
}
179179

0 commit comments

Comments
 (0)