mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-16 01:22:00 +00:00
fix: daemon_test.go allocation
This commit is contained in:
@@ -1655,9 +1655,13 @@ func TestResourceManager_ConcurrentAccess(t *testing.T) {
|
||||
// Goroutine 1: Allocate and deallocate
|
||||
go func() {
|
||||
for range iterations {
|
||||
// canAllocate -> allocate is non-atomic; allocate re-checks under
|
||||
// the write lock and may fail if another goroutine took the slot.
|
||||
// Only deallocate when allocate actually succeeded.
|
||||
if rm.canAllocate(microType, 1) >= 1 {
|
||||
rm.allocate(microType)
|
||||
rm.deallocate(microType)
|
||||
if err := rm.allocate(microType); err == nil {
|
||||
rm.deallocate(microType)
|
||||
}
|
||||
}
|
||||
}
|
||||
done <- true
|
||||
@@ -1675,8 +1679,9 @@ func TestResourceManager_ConcurrentAccess(t *testing.T) {
|
||||
go func() {
|
||||
for range iterations {
|
||||
if rm.canAllocate(microType, 1) >= 1 {
|
||||
rm.allocate(microType)
|
||||
rm.deallocate(microType)
|
||||
if err := rm.allocate(microType); err == nil {
|
||||
rm.deallocate(microType)
|
||||
}
|
||||
}
|
||||
}
|
||||
done <- true
|
||||
|
||||
Reference in New Issue
Block a user