Commit 1b34b381 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Test for read buffers too.

parent 9a0103bf
......@@ -41,6 +41,7 @@ type MountState struct {
reqPool []*request
readPool [][]byte
reqReaders int
outstandingReadBufs int
}
func (ms *MountState) KernelSettings() raw.InitIn {
......@@ -168,6 +169,7 @@ func (ms *MountState) readRequest() (req *request, code Status) {
} else {
dest = make([]byte, ms.opts.MaxWrite + 4096)
}
ms.outstandingReadBufs++
ms.reqReaders++
ms.reqMu.Unlock()
......@@ -185,6 +187,7 @@ func (ms *MountState) readRequest() (req *request, code Status) {
ms.reqMu.Lock()
if !gobbled {
ms.outstandingReadBufs--
ms.readPool = append(ms.readPool, dest)
dest = nil
}
......@@ -206,6 +209,7 @@ func (ms *MountState) returnRequest(req *request) {
ms.reqMu.Lock()
if req.bufferPoolOutputBuf != nil {
ms.readPool = append(ms.readPool, req.bufferPoolInputBuf)
ms.outstandingReadBufs--
req.bufferPoolInputBuf = nil
}
ms.reqPool = append(ms.reqPool, req)
......
......@@ -58,9 +58,12 @@ func TestMemoryPressure(t *testing.T) {
}(i)
}
time.Sleep(100 * time.Millisecond)
created := state.buffers.createdBuffers
created := state.buffers.createdBuffers + state.outstandingReadBufs
t.Logf("Have %d read bufs", state.outstandingReadBufs)
if created > 2 * _MAX_READERS {
t.Errorf("created %d buffers, max reader %d", created, _MAX_READERS)
}
wg.Wait()
}
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