Skip to content

Commit f910f64

Browse files
addaleaxcodebytere
authored andcommitted
http2: skip creating native ShutdownWrap
`ShutdownWrap` instances are being used to carry context between the start and the asynchronous end of shutting down the writable side of a `StreamBase`. HTTP/2 streams always perform this action synchronously, so no such object is necessary. PR-URL: #31283 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent fa0762d commit f910f64

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/node_http2.cc

+6
Original file line numberDiff line numberDiff line change
@@ -1987,6 +1987,12 @@ void Http2Stream::Close(int32_t code) {
19871987
Debug(this, "closed with code %d", code);
19881988
}
19891989

1990+
ShutdownWrap* Http2Stream::CreateShutdownWrap(v8::Local<v8::Object> object) {
1991+
// DoShutdown() always finishes synchronously, so there's no need to create
1992+
// a structure to store asynchronous context.
1993+
return nullptr;
1994+
}
1995+
19901996
int Http2Stream::DoShutdown(ShutdownWrap* req_wrap) {
19911997
if (IsDestroyed())
19921998
return UV_EPIPE;

src/node_http2.h

+1
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ class Http2Stream : public AsyncWrap,
472472
int ReadStop() override;
473473

474474
// Required for StreamBase
475+
ShutdownWrap* CreateShutdownWrap(v8::Local<v8::Object> object) override;
475476
int DoShutdown(ShutdownWrap* req_wrap) override;
476477

477478
bool HasWantsWrite() const override { return true; }

src/stream_base-inl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ inline int StreamBase::Shutdown(v8::Local<v8::Object> req_wrap_obj) {
162162
ShutdownWrap* req_wrap = CreateShutdownWrap(req_wrap_obj);
163163
int err = DoShutdown(req_wrap);
164164

165-
if (err != 0) {
165+
if (err != 0 && req_wrap != nullptr) {
166166
req_wrap->Dispose();
167167
}
168168

0 commit comments

Comments
 (0)