Skip to content

Commit

Permalink
Merge pull request #3 from creachadair/mjf/noderef-lock
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislusf authored Aug 21, 2023
2 parents fcffb10 + 238c0ba commit 4f81356
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fs/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ type Server struct {
meta sync.Mutex
req map[fuse.RequestID]func() // map request to cancel functions
node []*serveNode
nodeRefLock sync.Mutex
nodeRef map[Node]fuse.NodeID
inode2idLock sync.Mutex
inode2id map[uint64]fuse.NodeID
Expand Down Expand Up @@ -1716,6 +1717,8 @@ func (s *Server) getNodeId(node Node) (id fuse.NodeID, ok bool) {
s.inode2idLock.Unlock()
return
}
s.nodeRefLock.Lock()
defer s.nodeRefLock.Unlock()
id, ok = s.nodeRef[node]
return
}
Expand All @@ -1726,6 +1729,8 @@ func (s *Server) setNodeId(node Node, id fuse.NodeID) {
s.inode2idLock.Unlock()
return
}
s.nodeRefLock.Lock()
defer s.nodeRefLock.Unlock()
s.nodeRef[node] = id
}
func (s *Server) delNodeId(node Node) {
Expand All @@ -1735,6 +1740,8 @@ func (s *Server) delNodeId(node Node) {
s.inode2idLock.Unlock()
return
}
s.nodeRefLock.Lock()
defer s.nodeRefLock.Unlock()
delete(s.nodeRef, node)
}

Expand Down

0 comments on commit 4f81356

Please sign in to comment.