Open xiaoyulei opened 7 years ago
I write a simple program to test locker. I found locker2 can not get lock after locker1 Unlock.
locker2
locker1
Unlock
func main() { stopChan1 := make(chan struct{}) stopChan2 := make(chan struct{}) etcd.Register() s, _ := libkv.NewStore(store.ETCD, []string{"127.0.0.1:2379"}, nil) locker1, _ := s.NewLock("/test", &store.LockOptions{Value: []byte("testvalue"), TTL: 2 * time.Second}) locker2, _ := s.NewLock("/test", &store.LockOptions{Value: []byte("testvalue2"), TTL: 3 * time.Second}) fmt.Println("start lock locker1") locker1.Lock(stopChan1) fmt.Println("get locker1") go func() { fmt.Println("start lock locker2") locker2.Lock(stopChan2) fmt.Println("get locker2") locker2.Unlock() fmt.Println("unlock locker2") }() time.Sleep(3 * time.Second) fmt.Println("start unlock locker1") locker1.Unlock() fmt.Println("unlock locker1") time.Sleep(5 * time.Second) }
get locker1 start lock locker2 start unlock locker1 unlock locker1
This is fixed in abronan/libkv (I tested with that example)
This should be fixed by #186 which includes a test case for this.
I write a simple program to test locker. I found
locker2
can not get lock afterlocker1
Unlock
.