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 Trott committed Jan 11, 2020
1 parent 2a94c9f commit a523283
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
Expand Up @@ -1979,6 +1979,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
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
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 a523283

Please sign in to comment.