Commit f33f1679 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Fix data race in notify functions.

Writing the notification must be synchronized with closing the FUSE
connection.
parent 1aa32caa
...@@ -293,7 +293,10 @@ func (ms *MountState) Loop() { ...@@ -293,7 +293,10 @@ func (ms *MountState) Loop() {
ms.loops.Add(1) ms.loops.Add(1)
ms.loop(false) ms.loop(false)
ms.loops.Wait() ms.loops.Wait()
ms.reqMu.Lock()
ms.mountFile.Close() ms.mountFile.Close()
ms.reqMu.Unlock()
} }
func (ms *MountState) loop(exitIdle bool) { func (ms *MountState) loop(exitIdle bool) {
...@@ -460,7 +463,11 @@ func (ms *MountState) writeInodeNotify(entry *raw.NotifyInvalInodeOut) Status { ...@@ -460,7 +463,11 @@ func (ms *MountState) writeInodeNotify(entry *raw.NotifyInvalInodeOut) Status {
status: raw.NOTIFY_INVAL_INODE, status: raw.NOTIFY_INVAL_INODE,
} }
req.outData = unsafe.Pointer(entry) req.outData = unsafe.Pointer(entry)
// Protect against concurrent close.
ms.reqMu.Lock()
result := ms.write(&req) result := ms.write(&req)
ms.reqMu.Unlock()
if ms.Debug { if ms.Debug {
log.Println("Response: INODE_NOTIFY", result) log.Println("Response: INODE_NOTIFY", result)
...@@ -493,7 +500,11 @@ func (ms *MountState) writeDeleteNotify(parent uint64, child uint64, name string ...@@ -493,7 +500,11 @@ func (ms *MountState) writeDeleteNotify(parent uint64, child uint64, name string
nameBytes[len(nameBytes)-1] = '\000' nameBytes[len(nameBytes)-1] = '\000'
req.outData = unsafe.Pointer(entry) req.outData = unsafe.Pointer(entry)
req.flatData = nameBytes req.flatData = nameBytes
// Protect against concurrent close.
ms.reqMu.Lock()
result := ms.write(&req) result := ms.write(&req)
ms.reqMu.Unlock()
if ms.Debug { if ms.Debug {
log.Printf("Response: DELETE_NOTIFY: %v", result) log.Printf("Response: DELETE_NOTIFY: %v", result)
...@@ -521,7 +532,11 @@ func (ms *MountState) writeEntryNotify(parent uint64, name string) Status { ...@@ -521,7 +532,11 @@ func (ms *MountState) writeEntryNotify(parent uint64, name string) Status {
nameBytes[len(nameBytes)-1] = '\000' nameBytes[len(nameBytes)-1] = '\000'
req.outData = unsafe.Pointer(entry) req.outData = unsafe.Pointer(entry)
req.flatData = nameBytes req.flatData = nameBytes
// Protect against concurrent close.
ms.reqMu.Lock()
result := ms.write(&req) result := ms.write(&req)
ms.reqMu.Unlock()
if ms.Debug { if ms.Debug {
log.Printf("Response: ENTRY_NOTIFY: %v", result) log.Printf("Response: ENTRY_NOTIFY: %v", result)
......
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