File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,9 @@ var DisableSelectorCache = false
16
16
var SelectorCacheMaxEntries = 50
17
17
18
18
var (
19
- cacheOnce sync.Once
20
- cache * lru.Cache
21
- cacheMutex sync.RWMutex
19
+ cacheOnce sync.Once
20
+ cache * lru.Cache
21
+ cacheMutex sync.Mutex
22
22
)
23
23
24
24
func getQuery (expr string ) (* xpath.Expr , error ) {
@@ -28,14 +28,11 @@ func getQuery(expr string) (*xpath.Expr, error) {
28
28
cacheOnce .Do (func () {
29
29
cache = lru .New (SelectorCacheMaxEntries )
30
30
})
31
- cacheMutex .RLock ()
31
+ cacheMutex .Lock ()
32
+ defer cacheMutex .Unlock ()
32
33
if v , ok := cache .Get (expr ); ok {
33
- cacheMutex .RUnlock ()
34
34
return v .(* xpath.Expr ), nil
35
35
}
36
- cacheMutex .RUnlock ()
37
- cacheMutex .Lock ()
38
- defer cacheMutex .Unlock ()
39
36
v , err := xpath .Compile (expr )
40
37
if err != nil {
41
38
return nil , err
You can’t perform that action at this time.
0 commit comments