Skip to content

Commit b6d879f

Browse files
committed
[Server::patch] fixed distributed lock cannot get the correct lock
1 parent c749e60 commit b6d879f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

locker/mutex.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package locker
22

33
import (
4+
"errors"
45
"github.com/RealFax/RedQueen/internal/hack"
56
"time"
67

@@ -18,7 +19,7 @@ func MutexLock(lockID string, ttl int32, backend Backend) error {
1819
return uint32(ttl)
1920
}(),
2021
); err != nil {
21-
if err == store.ErrKeyAlreadyExists {
22+
if errors.Is(err, store.ErrKeyAlreadyExists) {
2223
return ErrStatusBusy
2324
}
2425
return err
@@ -27,8 +28,7 @@ func MutexLock(lockID string, ttl int32, backend Backend) error {
2728
}
2829

2930
func MutexUnlock(lockID string, backend Backend) error {
30-
val, err := backend.Get(hack.String2Bytes(lockID))
31-
if len(val.Data) == 0 || err == store.ErrKeyNotFound {
31+
if _, err := backend.Get(hack.String2Bytes(lockID)); errors.Is(err, store.ErrKeyNotFound) {
3232
return ErrStatusBusy
3333
}
3434
return backend.Del(hack.String2Bytes(lockID))

0 commit comments

Comments
 (0)