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 <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
addaleax authored and MylesBorins committed Jan 16, 2020
1 parent 6184f1a commit 52504fb
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 @@ -1959,6 +1959,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 @@ -470,6 +470,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 52504fb

Please sign in to comment.