修复崩溃的bug

This commit is contained in:
haidy 2019-03-24 09:29:38 +08:00
parent 1eb4a917fe
commit 003682366c

View File

@ -298,11 +298,18 @@ func (ctl *Control) worker() {
case <-ctl.closedCh: case <-ctl.closedCh:
// close related channels and wait until other goroutines done // close related channels and wait until other goroutines done
close(ctl.readCh) close(ctl.readCh)
if ctl.readerShutdown != nil {
ctl.readerShutdown.WaitDone() ctl.readerShutdown.WaitDone()
}
if ctl.msgHandlerShutdown != nil {
ctl.msgHandlerShutdown.WaitDone() ctl.msgHandlerShutdown.WaitDone()
}
close(ctl.sendCh) close(ctl.sendCh)
if ctl.writerShutdown != nil {
ctl.writerShutdown.WaitDone() ctl.writerShutdown.WaitDone()
}
ctl.pm.Close() ctl.pm.Close()
ctl.vm.Close() ctl.vm.Close()