Make a copy of handle in handleReadWriter.

Earlier we were storing a pointer, which was causing the handle to escape to
heap.

Suggested-by: Jamie Liu <jamieliu@google.com>
PiperOrigin-RevId: 609753000
This commit is contained in:
Ayush Ranjan
2024-02-23 09:37:08 -08:00
committed by gVisor bot
parent 88f7bb66f0
commit 255614124d
+3 -3
View File
@@ -104,7 +104,7 @@ func (h *handle) sync(ctx context.Context) error {
type handleReadWriter struct {
ctx context.Context
h *handle
h handle
off uint64
}
@@ -117,14 +117,14 @@ var handleReadWriterPool = sync.Pool{
func getHandleReadWriter(ctx context.Context, h *handle, offset int64) *handleReadWriter {
rw := handleReadWriterPool.Get().(*handleReadWriter)
rw.ctx = ctx
rw.h = h
rw.h = *h
rw.off = uint64(offset)
return rw
}
func putHandleReadWriter(rw *handleReadWriter) {
rw.ctx = nil
rw.h = nil
rw.h = noHandle
handleReadWriterPool.Put(rw)
}