client_locks_test.go 720 B

1234567891011121314151617181920212223242526272829
  1. package service
  2. import (
  3. "testing"
  4. "time"
  5. )
  6. // lockInbound must not hold the global registry mutex while it waits on a busy
  7. // inbound's own mutex, otherwise one slow client operation on a single inbound
  8. // freezes client mutations on every other inbound panel-wide.
  9. func TestLockInboundReleasesRegistryMutexWhileWaiting(t *testing.T) {
  10. const id = 990006
  11. held := lockInbound(id)
  12. parked := make(chan struct{})
  13. go func() {
  14. close(parked)
  15. lockInbound(id).Unlock()
  16. }()
  17. <-parked
  18. time.Sleep(50 * time.Millisecond)
  19. if !inboundMutationLocksMu.TryLock() {
  20. held.Unlock()
  21. t.Fatal("registry mutex is held while a lockInbound caller waits on a busy inbound")
  22. }
  23. inboundMutationLocksMu.Unlock()
  24. held.Unlock()
  25. }