aboutsummaryrefslogtreecommitdiff
path: root/weed/wdclient/masterclient.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-09-09 12:07:15 -0700
committerChris Lu <chris.lu@gmail.com>2020-09-09 12:07:15 -0700
commitdaf0a449f7424d4a8252673509af5afd0b9bd8ec (patch)
treee9b9ba152b2fade26b71e7710ae6730dafe9d39e /weed/wdclient/masterclient.go
parent7f69acd1f21b4e42afff155b633419eda17af331 (diff)
downloadseaweedfs-daf0a449f7424d4a8252673509af5afd0b9bd8ec.tar.xz
seaweedfs-daf0a449f7424d4a8252673509af5afd0b9bd8ec.zip
properly cancel context for streaming grpc
Diffstat (limited to 'weed/wdclient/masterclient.go')
-rw-r--r--weed/wdclient/masterclient.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/weed/wdclient/masterclient.go b/weed/wdclient/masterclient.go
index 4c066d535..3d23d8f13 100644
--- a/weed/wdclient/masterclient.go
+++ b/weed/wdclient/masterclient.go
@@ -70,7 +70,10 @@ func (mc *MasterClient) tryConnectToMaster(master string) (nextHintedLeader stri
glog.V(1).Infof("%s masterClient Connecting to master %v", mc.clientType, master)
gprcErr := pb.WithMasterClient(master, mc.grpcDialOption, func(client master_pb.SeaweedClient) error {
- stream, err := client.KeepConnected(context.Background())
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+
+ stream, err := client.KeepConnected(ctx)
if err != nil {
glog.V(0).Infof("%s masterClient failed to keep connected to %s: %v", mc.clientType, master, err)
return err