aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-09-10 19:51:03 -0700
committerChris Lu <chris.lu@gmail.com>2020-09-10 19:51:03 -0700
commiteaf9fdde99af84ca89baf37432dfe985ee7b1385 (patch)
tree063ec13fa6b2aaa43fbc1f6bd8ac50b28e4e6f26
parentcc5fe6f5eeb1936f172d0b6e409826c6420454e9 (diff)
downloadseaweedfs-eaf9fdde99af84ca89baf37432dfe985ee7b1385.tar.xz
seaweedfs-eaf9fdde99af84ca89baf37432dfe985ee7b1385.zip
avoid sharing context over separate goroutine
-rw-r--r--weed/wdclient/exclusive_locks/exclusive_locker.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/weed/wdclient/exclusive_locks/exclusive_locker.go b/weed/wdclient/exclusive_locks/exclusive_locker.go
index 801de14ce..d477a6b2d 100644
--- a/weed/wdclient/exclusive_locks/exclusive_locker.go
+++ b/weed/wdclient/exclusive_locks/exclusive_locker.go
@@ -74,9 +74,12 @@ func (l *ExclusiveLocker) RequestLock() {
// start a goroutine to renew the lease
go func() {
+ ctx2, cancel2 := context.WithCancel(context.Background())
+ defer cancel2()
+
for l.isLocking {
if err := l.masterClient.WithClient(func(client master_pb.SeaweedClient) error {
- resp, err := client.LeaseAdminToken(ctx, &master_pb.LeaseAdminTokenRequest{
+ resp, err := client.LeaseAdminToken(ctx2, &master_pb.LeaseAdminTokenRequest{
PreviousToken: atomic.LoadInt64(&l.token),
PreviousLockTime: atomic.LoadInt64(&l.lockTsNs),
LockName: AdminLockName,