Commit 100c7af2 authored by Aaron Jacobs's avatar Aaron Jacobs

Put a wait group in fileSystemServer.

parent 683decb0
...@@ -18,6 +18,7 @@ import ( ...@@ -18,6 +18,7 @@ import (
"flag" "flag"
"io" "io"
"math/rand" "math/rand"
"sync"
"time" "time"
"github.com/jacobsa/fuse" "github.com/jacobsa/fuse"
...@@ -73,11 +74,14 @@ type FileSystem interface { ...@@ -73,11 +74,14 @@ type FileSystem interface {
// cf. http://goo.gl/jnkHPO, fuse-devel thread "Fuse guarantees on concurrent // cf. http://goo.gl/jnkHPO, fuse-devel thread "Fuse guarantees on concurrent
// requests"). // requests").
func NewFileSystemServer(fs FileSystem) fuse.Server { func NewFileSystemServer(fs FileSystem) fuse.Server {
return fileSystemServer{fs} return fileSystemServer{
fs: fs,
}
} }
type fileSystemServer struct { type fileSystemServer struct {
fs FileSystem fs FileSystem
opsInFlight sync.WaitGroup
} }
func (s fileSystemServer) ServeOps(c *fuse.Connection) { func (s fileSystemServer) ServeOps(c *fuse.Connection) {
...@@ -91,6 +95,7 @@ func (s fileSystemServer) ServeOps(c *fuse.Connection) { ...@@ -91,6 +95,7 @@ func (s fileSystemServer) ServeOps(c *fuse.Connection) {
panic(err) panic(err)
} }
s.opsInFlight.Add(1)
go s.handleOp(op) go s.handleOp(op)
} }
} }
...@@ -171,4 +176,5 @@ func (s fileSystemServer) handleOp(op fuseops.Op) { ...@@ -171,4 +176,5 @@ func (s fileSystemServer) handleOp(op fuseops.Op) {
} }
op.Respond(err) op.Respond(err)
s.opsInFlight.Done()
} }
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