Define that Server.ServeOps must wait for in-flights.
parent
100c7af28a
commit
5ae9856c29
|
@ -74,7 +74,7 @@ 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{
|
return &fileSystemServer{
|
||||||
fs: fs,
|
fs: fs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,9 @@ type fileSystemServer struct {
|
||||||
opsInFlight sync.WaitGroup
|
opsInFlight sync.WaitGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s fileSystemServer) ServeOps(c *fuse.Connection) {
|
func (s *fileSystemServer) ServeOps(c *fuse.Connection) {
|
||||||
|
defer s.opsInFlight.Wait()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
op, err := c.ReadOp()
|
op, err := c.ReadOp()
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
|
@ -100,7 +102,9 @@ func (s fileSystemServer) ServeOps(c *fuse.Connection) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s fileSystemServer) handleOp(op fuseops.Op) {
|
func (s *fileSystemServer) handleOp(op fuseops.Op) {
|
||||||
|
defer s.opsInFlight.Done()
|
||||||
|
|
||||||
// Delay if requested.
|
// Delay if requested.
|
||||||
if *fRandomDelays {
|
if *fRandomDelays {
|
||||||
const delayLimit = 100 * time.Microsecond
|
const delayLimit = 100 * time.Microsecond
|
||||||
|
@ -176,5 +180,4 @@ func (s fileSystemServer) handleOp(op fuseops.Op) {
|
||||||
}
|
}
|
||||||
|
|
||||||
op.Respond(err)
|
op.Respond(err)
|
||||||
s.opsInFlight.Done()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,8 @@ import (
|
||||||
|
|
||||||
// A type that knows how to serve ops read from a connection.
|
// A type that knows how to serve ops read from a connection.
|
||||||
type Server interface {
|
type Server interface {
|
||||||
// Read and serve ops from the supplied connection until EOF.
|
// Read and serve ops from the supplied connection until EOF. Do not return
|
||||||
|
// until all operations have been responded to.
|
||||||
ServeOps(*Connection)
|
ServeOps(*Connection)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue