mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user