Skip to content

Commit 52504fb

Browse files
addaleaxMylesBorins
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 <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 6184f1a commit 52504fb

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
@@ -1959,6 +1959,12 @@ void Http2Stream::Close(int32_t code) {
19591959
Debug(this, "closed with code %d", code);
19601960
}
19611961

1962+
ShutdownWrap* Http2Stream::CreateShutdownWrap(v8::Local<v8::Object> object) {
1963+
// DoShutdown() always finishes synchronously, so there's no need to create
1964+
// a structure to store asynchronous context.
1965+
return nullptr;
1966+
}
1967+
19621968
int Http2Stream::DoShutdown(ShutdownWrap* req_wrap) {
19631969
if (IsDestroyed())
19641970
return UV_EPIPE;

src/node_http2.h

+1
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ class Http2Stream : public AsyncWrap,
470470
int ReadStop() override;
471471

472472
// Required for StreamBase
473+
ShutdownWrap* CreateShutdownWrap(v8::Local<v8::Object> object) override;
473474
int DoShutdown(ShutdownWrap* req_wrap) override;
474475

475476
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)