From 75a65d4a03cd7f6b6db9291e61ff41e18f3f476d Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Tue, 3 Mar 2015 09:39:45 +1100 Subject: [PATCH] Fixed a locking bug. --- samples/memfs/fs.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/memfs/fs.go b/samples/memfs/fs.go index 5340c75..10cfc55 100644 --- a/samples/memfs/fs.go +++ b/samples/memfs/fs.go @@ -149,8 +149,9 @@ func (fs *memFS) getInodeForReadingOrDie(id fuse.InodeID) (inode *inode) { // EXCLUSIVE_LOCK_FUNCTION(inode.mu) func (fs *memFS) allocateInode( mode os.FileMode) (id fuse.InodeID, inode *inode) { - // Create the inode. + // Create and lock the inode. inode = newInode(mode) + inode.mu.Lock() // Re-use a free ID if possible. Otherwise mint a new one. numFree := len(fs.freeInodes)