GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — http2: fix GC issue & typos by apapirovski · Pull Request #21194 · nodejs/node

http2: fix GC issue & typos #21194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
apapirovski wants to merge 4 commits into nodejs:master from apapirovski:patch-http2-fixes

Uh oh!

There was an error while loading. Please reload this page.

Closed

http2: fix GC issue & typos #21194

Changes from all commits
Commits
Show all changes
4 commits
Select commit Hold shift + click to select a range
2c16d3c
http2: safer Http2Session destructor
apapirovski Jun 6, 2018
f602aab
src: fix http2 typos
apapirovski Jun 6, 2018
7abe1d8
fixup: another segfault
apapirovski Jun 7, 2018
4c9aa9c
fixup: addaleax feedback
apapirovski Jun 7, 2018
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

23 changes: 13 additions & 10 deletions 23 src/node_http2.cc
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,8 @@ Http2Session::Http2Session(Environment* env,
Http2Session::~Http2Session() {
CHECK_EQ(flags_ & SESSION_STATE_HAS_SCOPE, 0);
Debug(this, "freeing nghttp2 session");
for (const auto& stream : streams_)
stream.second->session_ = nullptr;
nghttp2_session_del(session_);
}

Expand All @@ -519,7 +521,7 @@ void Http2Stream::EmitStatistics() {
Http2StreamPerformanceEntry* entry =
new Http2StreamPerformanceEntry(env(), id_, statistics_);
env()->SetImmediate([](Environment* env, void* data) {
// This takes ownership, the entr is destroyed at the end of this scope.
// This takes ownership, the entry is destroyed at the end of this scope.
std::unique_ptr<Http2StreamPerformanceEntry> entry {
static_cast<Http2StreamPerformanceEntry*>(data) };
if (!HasHttp2Observer(env))
Expand Down Expand Up @@ -996,7 +998,7 @@ int Http2Session::OnDataChunkReceived(nghttp2_session* handle,
// `buf.base == nullptr` is the default Http2StreamListener's way
// of saying that it wants a pointer to the raw original.
// Since it has access to the original socket buffer from which the data
// was read in the first place, it can use that to minizime ArrayBuffer
// was read in the first place, it can use that to minimize ArrayBuffer
Comment thread Outdated

@addaleax addaleax Jun 7, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😎

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
// allocations.
if (LIKELY(buf.base == nullptr))
buf.base = reinterpret_cast<char*>(const_cast<uint8_t*>(data));
Expand Down Expand Up @@ -1336,7 +1338,7 @@ void Http2Session::OnStreamAfterWrite(WriteWrap* w, int status) {
}

// If the underlying nghttp2_session struct has data pending in its outbound
// queue, MaybeScheduleWrite will schedule a SendPendingData() call to occcur
// queue, MaybeScheduleWrite will schedule a SendPendingData() call to occur
// on the next iteration of the Node.js event loop (using the SetImmediate
// queue), but only if a write has not already been scheduled.
void Http2Session::MaybeScheduleWrite() {
Expand Down Expand Up @@ -1706,11 +1708,11 @@ Http2Stream::Http2Stream(


Http2Stream::~Http2Stream() {
if (session_ == nullptr)
return;
Debug(this, "tearing down stream");
if (session_ != nullptr) {
session_->RemoveStream(this);
session_ = nullptr;
}
session_->RemoveStream(this);
session_ = nullptr;
}

std::string Http2Stream::diagnostic_name() const {
Expand Down Expand Up @@ -1785,7 +1787,8 @@ void Http2Stream::Destroy() {
// We can destroy the stream now if there are no writes for it
// already on the socket. Otherwise, we'll wait for the garbage collector
// to take care of cleaning up.
if (!stream->session()->HasWritesOnSocketForStream(stream))
if (stream->session() == nullptr ||
!stream->session()->HasWritesOnSocketForStream(stream))
delete stream;
}, this, this->object());

Expand Down Expand Up @@ -2177,7 +2180,7 @@ void Http2Session::RefreshSettings(const FunctionCallbackInfo<Value>& args) {

// A TypedArray instance is shared between C++ and JS land to contain state
// information of the current Http2Session. This updates the values in the
// TypedRray so those can be read in JS land.
// TypedArray so those can be read in JS land.
void Http2Session::RefreshState(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Http2Session* session;
Expand Down Expand Up @@ -2510,7 +2513,7 @@ void Http2Session::AltSvc(int32_t id,
origin, origin_len, value, value_len), 0);
}

// Submits an AltSvc frame to the sent to the connected peer.
// Submits an AltSvc frame to be sent to the connected peer.
void Http2Session::AltSvc(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Http2Session* session;
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.