mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-05-19 14:06:32 +02:00
Fix race condition when accessing "expected" in proxy_config tests.
This commit is contained in:
parent
9da78a1a8b
commit
48424bf290
|
@ -121,6 +121,9 @@ func (p *mcuProxyForConfig) checkEvent(event *proxyConfigEvent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.mu.Lock()
|
||||||
|
defer p.mu.Unlock()
|
||||||
|
|
||||||
if len(p.expected) == 0 {
|
if len(p.expected) == 0 {
|
||||||
p.t.Errorf("no event expected, got %+v from %s:%d", event, caller.File, caller.Line)
|
p.t.Errorf("no event expected, got %+v from %s:%d", event, caller.File, caller.Line)
|
||||||
return
|
return
|
||||||
|
@ -128,10 +131,10 @@ func (p *mcuProxyForConfig) checkEvent(event *proxyConfigEvent) {
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if len(p.expected) == 0 {
|
if len(p.expected) == 0 {
|
||||||
p.mu.Lock()
|
|
||||||
waiters := p.waiters
|
waiters := p.waiters
|
||||||
p.waiters = nil
|
p.waiters = nil
|
||||||
p.mu.Unlock()
|
p.mu.Unlock()
|
||||||
|
defer p.mu.Lock()
|
||||||
|
|
||||||
for _, ch := range waiters {
|
for _, ch := range waiters {
|
||||||
ch <- struct{}{}
|
ch <- struct{}{}
|
||||||
|
@ -139,8 +142,6 @@ func (p *mcuProxyForConfig) checkEvent(event *proxyConfigEvent) {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
p.mu.Lock()
|
|
||||||
defer p.mu.Unlock()
|
|
||||||
expected := p.expected[0]
|
expected := p.expected[0]
|
||||||
p.expected = p.expected[1:]
|
p.expected = p.expected[1:]
|
||||||
if !reflect.DeepEqual(expected, *event) {
|
if !reflect.DeepEqual(expected, *event) {
|
||||||
|
|
Loading…
Reference in a new issue