Skip to content

Commit

Permalink
Merge pull request #56 from wunderio/feature/map-context-concurrency
Browse files Browse the repository at this point in the history
Map context concurrency fix
  • Loading branch information
Jancis authored Sep 12, 2024
2 parents b02e177 + 87768d0 commit 52bf6f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.0.0
v3.0.1
8 changes: 8 additions & 0 deletions pkg/rclone/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os/exec"
"strconv"
"strings"
"sync"
"time"

v1 "k8s.io/api/core/v1"
Expand All @@ -36,16 +37,21 @@ type nodeServer struct {
*csicommon.DefaultNodeServer
mounter *mount.SafeFormatAndMount
mountContext map[string]*mountContext
mu sync.RWMutex
}

func (ns *nodeServer) getMountContext(targetPath string) *mountContext {
ns.mu.RLock()
defer ns.mu.RUnlock()
if mc, ok := ns.mountContext[targetPath]; ok {
return mc
}
return &mountContext{}
}

func (ns *nodeServer) setMountContext(targetPath string, mc *mountContext) {
ns.mu.Lock()
defer ns.mu.Unlock()
// create a new mount context
if ns.mountContext == nil {
ns.mountContext = make(map[string]*mountContext)
Expand All @@ -54,6 +60,8 @@ func (ns *nodeServer) setMountContext(targetPath string, mc *mountContext) {
}

func (ns *nodeServer) deleteMountContext(targetPath string) {
ns.mu.Lock()
defer ns.mu.Unlock()
delete(ns.mountContext, targetPath)
}

Expand Down

0 comments on commit 52bf6f3

Please sign in to comment.