diff options
author | Anna Henningsen <anna@addaleax.net> | 2020-10-03 23:44:55 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2020-10-06 14:26:33 +0300 |
commit | 78e58755f71d7d59901de1c7e2712cebe4de0ef1 (patch) | |
tree | 8b7a55e28352f785718297009975e76517d0b11f /src/node_http2.h | |
parent | fb2f3cc828e47215ab5dbcc1e5bb911b0cde9e38 (diff) |
http2,tls: store WriteWrap using BaseObjectPtr
Create weak `WriteWrap` and `ShutdownWrap` objects, and when
referencing them in C++ is necessary, use `BaseObjectPtr<>`
instead of plain pointers to keep these objects from being
garbage-collected.
This solves issues that arise when the underlying `StreamBase`
instance is weak, but the `WriteWrap` or `ShutdownWrap` instances
are not; in that case, they would otherwise potentially stick
around in memory after the stream that they originally belong
to is long gone.
It probably makes sense to use `BaseObjectptr<>` more extensively
in `StreamBase` in the long run as well.
PR-URL: https://github.com/nodejs/node/pull/35488
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'src/node_http2.h')
-rw-r--r-- | src/node_http2.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/node_http2.h b/src/node_http2.h index f0c79cd27de..79cbe7613b5 100644 --- a/src/node_http2.h +++ b/src/node_http2.h @@ -144,12 +144,12 @@ using Http2Headers = NgHeaders<Http2HeadersTraits>; using Http2RcBufferPointer = NgRcBufPointer<Http2RcBufferPointerTraits>; struct NgHttp2StreamWrite : public MemoryRetainer { - WriteWrap* req_wrap = nullptr; + BaseObjectPtr<AsyncWrap> req_wrap; uv_buf_t buf; inline explicit NgHttp2StreamWrite(uv_buf_t buf_) : buf(buf_) {} - inline NgHttp2StreamWrite(WriteWrap* req, uv_buf_t buf_) : - req_wrap(req), buf(buf_) {} + inline NgHttp2StreamWrite(BaseObjectPtr<AsyncWrap> req_wrap, uv_buf_t buf_) : + req_wrap(std::move(req_wrap)), buf(buf_) {} void MemoryInfo(MemoryTracker* tracker) const override; SET_MEMORY_INFO_NAME(NgHttp2StreamWrite) |