Skip to content

Commit

Permalink
http2: skip creating native ShutdownWrap
Browse files Browse the repository at this point in the history
`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>
  • Loading branch information
addaleax authored and codebytere committed Mar 17, 2020
1 parent fa0762d commit f910f64
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/node_http2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1987,6 +1987,12 @@ void Http2Stream::Close(int32_t code) {
Debug(this, "closed with code %d", code);
}

ShutdownWrap* Http2Stream::CreateShutdownWrap(v8::Local<v8::Object> object) {
// DoShutdown() always finishes synchronously, so there's no need to create
// a structure to store asynchronous context.
return nullptr;
}

int Http2Stream::DoShutdown(ShutdownWrap* req_wrap) {
if (IsDestroyed())
return UV_EPIPE;
Expand Down
1 change: 1 addition & 0 deletions src/node_http2.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ class Http2Stream : public AsyncWrap,
int ReadStop() override;

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

bool HasWantsWrite() const override { return true; }
Expand Down
2 changes: 1 addition & 1 deletion src/stream_base-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ inline int StreamBase::Shutdown(v8::Local<v8::Object> req_wrap_obj) {
ShutdownWrap* req_wrap = CreateShutdownWrap(req_wrap_obj);
int err = DoShutdown(req_wrap);

if (err != 0) {
if (err != 0 && req_wrap != nullptr) {
req_wrap->Dispose();
}

Expand Down

0 comments on commit f910f64

Please sign in to comment.