Webhub race condition (#9863)
* fix webconn close semantics Avoid race conditions in WebConn on shutdown by closing channels to guarantee all readers are notified. Wrap this with sync.Once to avoid closing the channel more than once. * web_hub_test.go * webhub: fix race condition on shutdown Ensure that if the webhub shuts down in the process of sending, the caller unblocks given that the webhub will no longer consume incoming events. * panic if app shutdown takes >30 seconds * simplify WebConn::Pump channel semantics too
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
1271908182
Коммит
f8ffd68060
@@ -179,10 +179,26 @@ func SetupConfig(updateConfig func(cfg *model.Config)) *TestHelper {
|
||||
return setupTestHelper(false, updateConfig)
|
||||
}
|
||||
|
||||
func (me *TestHelper) ShutdownApp() {
|
||||
done := make(chan bool)
|
||||
go func() {
|
||||
me.App.Shutdown()
|
||||
close(done)
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(30 * time.Second):
|
||||
// panic instead of t.Fatal to terminate all tests in this package, otherwise the
|
||||
// still running App could spuriously fail subsequent tests.
|
||||
panic("failed to shutdown App within 30 seconds")
|
||||
}
|
||||
}
|
||||
|
||||
func (me *TestHelper) TearDown() {
|
||||
utils.DisableDebugLogForTest()
|
||||
|
||||
me.App.Shutdown()
|
||||
me.ShutdownApp()
|
||||
os.Remove(me.tempConfigPath)
|
||||
|
||||
utils.EnableDebugLogForTest()
|
||||
|
||||
Ссылка в новой задаче
Block a user