mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
kvm: fix race between machine.Put and machine.Get
m.available.Signal() has to be called under m.mu.RLock, otherwise it can race with machine.Get: m.Get | m.Put ------------------------------------- m.mu.Lock() | Seatching available vcpu| | m.available.Signal() m.available.Wait | PiperOrigin-RevId: 259394051
This commit is contained in:
@@ -388,7 +388,10 @@ func (m *machine) Get() *vCPU {
|
||||
func (m *machine) Put(c *vCPU) {
|
||||
c.unlock()
|
||||
runtime.UnlockOSThread()
|
||||
|
||||
m.mu.RLock()
|
||||
m.available.Signal()
|
||||
m.mu.RUnlock()
|
||||
}
|
||||
|
||||
// newDirtySet returns a new dirty set.
|
||||
|
||||
Reference in New Issue
Block a user