diff options
Diffstat (limited to 'src/runtime/vgetrandom_linux.go')
| -rw-r--r-- | src/runtime/vgetrandom_linux.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/runtime/vgetrandom_linux.go b/src/runtime/vgetrandom_linux.go index 00ef2c2d4e..6ab12e3c67 100644 --- a/src/runtime/vgetrandom_linux.go +++ b/src/runtime/vgetrandom_linux.go @@ -74,9 +74,16 @@ func vgetrandomGetState() uintptr { return state } -func vgetrandomPutState(state uintptr) { +// Free vgetrandom state from the M (if any) prior to destroying the M. +// +// This may allocate, so it must have a P. +func vgetrandomDestroy(mp *m) { + if mp.vgetrandomState == 0 { + return + } + lock(&vgetrandomAlloc.statesLock) - vgetrandomAlloc.states = append(vgetrandomAlloc.states, state) + vgetrandomAlloc.states = append(vgetrandomAlloc.states, mp.vgetrandomState) unlock(&vgetrandomAlloc.statesLock) } |
