mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-05-17 04:56:33 +02:00
Merge pull request #652 from strukturag/fix-proxy-config-test-race
Fix race condition when accessing "expected" in proxy_config tests.
This commit is contained in:
commit
d71ca35e97
|
@ -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