From 0f62458e212999a0ea8e285dacd2e07d1400035d Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Tue, 9 Jun 2015 11:11:52 +1000 Subject: [PATCH] Destroy when done. --- fuseutil/file_system.go | 7 ++++++- mounted_file_system.go | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fuseutil/file_system.go b/fuseutil/file_system.go index f1ed0a3..18510aa 100644 --- a/fuseutil/file_system.go +++ b/fuseutil/file_system.go @@ -90,7 +90,12 @@ type fileSystemServer struct { } func (s *fileSystemServer) ServeOps(c *fuse.Connection) { - defer s.opsInFlight.Wait() + // When we are done, we clean up by waiting for all in-flight ops then + // destroying the file system. + defer func() { + s.opsInFlight.Wait() + s.fs.Destroy() + }() for { op, err := c.ReadOp() diff --git a/mounted_file_system.go b/mounted_file_system.go index 4055a3d..9335cd9 100644 --- a/mounted_file_system.go +++ b/mounted_file_system.go @@ -27,7 +27,8 @@ import ( // A type that knows how to serve ops read from a connection. type Server interface { // Read and serve ops from the supplied connection until EOF. Do not return - // until all operations have been responded to. + // until all operations have been responded to. Must not be called more than + // once. ServeOps(*Connection) }