aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-12-10 02:51:21 +0800
committerFelix Lange <fjl@twurst.com>2017-01-26 01:44:21 +0800
commita2b4abd89adf0404b43fcd19766bac37009032a5 (patch)
tree11418c1522944167930c1ec0d3e6ade8b581ea6a /rpc
parent6d5e100d0dc6fc0b905610850a75b5d4fa907739 (diff)
downloadgo-tangerine-a2b4abd89adf0404b43fcd19766bac37009032a5.tar
go-tangerine-a2b4abd89adf0404b43fcd19766bac37009032a5.tar.gz
go-tangerine-a2b4abd89adf0404b43fcd19766bac37009032a5.tar.bz2
go-tangerine-a2b4abd89adf0404b43fcd19766bac37009032a5.tar.lz
go-tangerine-a2b4abd89adf0404b43fcd19766bac37009032a5.tar.xz
go-tangerine-a2b4abd89adf0404b43fcd19766bac37009032a5.tar.zst
go-tangerine-a2b4abd89adf0404b43fcd19766bac37009032a5.zip
rpc: send nil on subscription Err channel when Client is closed
This change makes client subscriptions compatible with the new Subscription semantics introduced in the previous commit.
Diffstat (limited to 'rpc')
-rw-r--r--rpc/client.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/rpc/client.go b/rpc/client.go
index 34a3b7831..269eb78c8 100644
--- a/rpc/client.go
+++ b/rpc/client.go
@@ -682,7 +682,7 @@ func newClientSubscription(c *Client, channel reflect.Value) *ClientSubscription
// resubscription when the client connection is closed unexpectedly.
//
// The error channel receives a value when the subscription has ended due
-// to an error. The received error is ErrClientQuit if Close has been called
+// to an error. The received error is nil if Close has been called
// on the underlying client and no other error has occurred.
//
// The error channel is closed when Unsubscribe is called on the subscription.
@@ -707,6 +707,9 @@ func (sub *ClientSubscription) quitWithError(err error, unsubscribeServer bool)
sub.requestUnsubscribe()
}
if err != nil {
+ if err == ErrClientQuit {
+ err = nil // Adhere to subscription semantics.
+ }
sub.err <- err
}
})