Commit 40eebacb authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Add WaitMount() to wait for first request being done.

parent 90e49967
......@@ -91,6 +91,8 @@ func NewTestCase(t *testing.T) *testCase {
// Unthreaded, but in background.
go me.state.Loop()
me.state.WaitMount()
return me
}
......
......@@ -35,6 +35,8 @@ type MountState struct {
opts *MountOptions
started chan struct {}
reqMu sync.Mutex
reqPool []*request
readPool [][]byte
......@@ -182,6 +184,7 @@ func NewMountState(fs RawFileSystem) *MountState {
ms := new(MountState)
ms.mountPoint = ""
ms.fileSystem = fs
ms.started = make(chan struct{})
return ms
}
......@@ -385,7 +388,11 @@ func (ms *MountState) write(req *request) Status {
return OK
}
return ms.systemWrite(req, header)
s := ms.systemWrite(req, header)
if req.inHeader.Opcode == _OP_INIT {
close(ms.started)
}
return s
}
func (ms *MountState) writeInodeNotify(entry *raw.NotifyInvalInodeOut) Status {
......@@ -483,3 +490,10 @@ var defaultBufferPool BufferPool
func init() {
defaultBufferPool = NewBufferPool()
}
// Wait for the first request to be served. Use this to avoid racing
// between accessing the (empty) mountpoint, and the OS trying to
// setup the user-space mount.
func (ms *MountState) WaitMount() {
<-ms.started
}
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