eliminate potential deadlock/dealy in connection.Shutdown

Treat the no-error case the same as the error case...
- use the standard sendAction to communicate with the actor, which
  ensures that we don't block when the actor has terminated
- run in a goroutine to prevent delaying the caller when the actor's
  channel is backed up.
This commit is contained in:
Matthias Radestock committed 2015-03-26 13:25:23 +00:00
1 parent dbe39659c5
commit 31efd76797
1 file changed
+7 -6
+7 -6
View File
@@ -188,12 +188,13 @@ func (conn *LocalConnection) SendProtocolMsg(m ProtocolMsg) {
// Async
func (conn *LocalConnection) Shutdown(err error) {
if err == nil {
conn.actionChan <- nil
} else {
// Run on its own goroutine in case the channel is backed up
go func() { conn.sendAction(func() error { return err }) }()
}
// Run on its own goroutine in case the channel is backed up
go func() {
if err == nil {
conn.sendAction(nil)
} else {
conn.sendAction(func() error { return err }) }
}()
}
// Async