Commit 4dece6d7 authored by lch's avatar lch Committed by Han-Wen Nienhuys

fuse: fix hang under Darwin and FreeBSD when umount

Both FreeBSD and Darwin must use a single reader to access the FUSE device.

Change-Id: I51c467bb0b8e1fda871665d033dd89d11fbe961c
parent 1072b7f0
...@@ -195,14 +195,11 @@ func NewServer(fs RawFileSystem, mountPoint string, opts *MountOptions) (*Server ...@@ -195,14 +195,11 @@ func NewServer(fs RawFileSystem, mountPoint string, opts *MountOptions) (*Server
} }
ms := &Server{ ms := &Server{
fileSystem: fs, fileSystem: fs,
opts: &o, opts: &o,
maxReaders: maxReaders, maxReaders: maxReaders,
retrieveTab: make(map[uint64]*retrieveCacheRequest), retrieveTab: make(map[uint64]*retrieveCacheRequest),
// OSX has races when multiple routines read from the singleReader: useSingleReader,
// FUSE device: on unmount, sometime some reads do not
// error-out, meaning that unmount will hang.
singleReader: runtime.GOOS == "darwin",
ready: make(chan error, 1), ready: make(chan error, 1),
} }
ms.reqPool.New = func() interface{} { ms.reqPool.New = func() interface{} {
......
...@@ -8,6 +8,8 @@ import ( ...@@ -8,6 +8,8 @@ import (
"syscall" "syscall"
) )
const useSingleReader = false
func (ms *Server) systemWrite(req *request, header []byte) Status { func (ms *Server) systemWrite(req *request, header []byte) Status {
if req.flatDataSize() == 0 { if req.flatDataSize() == 0 {
err := handleEINTR(func() error { err := handleEINTR(func() error {
......
...@@ -6,6 +6,11 @@ import ( ...@@ -6,6 +6,11 @@ import (
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
// OSX and FreeBSD has races when multiple routines read
// from the FUSE device: on unmount, sometime some reads
// do not error-out, meaning that unmount will hang.
const useSingleReader = true
func (ms *Server) systemWrite(req *request, header []byte) Status { func (ms *Server) systemWrite(req *request, header []byte) Status {
if req.flatDataSize() == 0 { if req.flatDataSize() == 0 {
err := handleEINTR(func() error { err := handleEINTR(func() error {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment