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 // Async
func (conn *LocalConnection) Shutdown(err error) { func (conn *LocalConnection) Shutdown(err error) {
if err == nil { // Run on its own goroutine in case the channel is backed up
conn.actionChan <- nil go func() {
} else { if err == nil {
// Run on its own goroutine in case the channel is backed up conn.sendAction(nil)
go func() { conn.sendAction(func() error { return err }) }() } else {
} conn.sendAction(func() error { return err }) }
}()
} }
// Async // Async