Skip to content

Commit

Permalink
http2: fixup http2stream cleanup and other nits
Browse files Browse the repository at this point in the history
  • Loading branch information
jasnell authored and evanlucas committed Jun 12, 2018
1 parent f0af3b0 commit 828159f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/node_http2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@ Http2Session::Http2Session(Environment* env,
Http2Session::~Http2Session() {
CHECK_EQ(flags_ & SESSION_STATE_HAS_SCOPE, 0);
DEBUG_HTTP2SESSION(this, "freeing nghttp2 session");
for (const auto& iter : streams_)
iter.second->session_ = nullptr;
nghttp2_session_del(session_);
}

Expand Down Expand Up @@ -643,6 +645,8 @@ inline void Http2Session::AddStream(Http2Stream* stream) {


inline void Http2Session::RemoveStream(Http2Stream* stream) {
if (streams_.empty() || stream == nullptr)
return; // Nothing to remove, item was never added?
streams_.erase(stream->id());
DecrementCurrentSessionMemory(stream->self_size());
}
Expand Down Expand Up @@ -1697,8 +1701,8 @@ Http2Stream::Http2Stream(


Http2Stream::~Http2Stream() {
DEBUG_HTTP2STREAM(this, "tearing down stream");
if (session_ != nullptr) {
DEBUG_HTTP2STREAM(this, "tearing down stream");
session_->RemoveStream(this);
session_ = nullptr;
}
Expand Down
4 changes: 2 additions & 2 deletions src/node_http2.h
Original file line number Diff line number Diff line change
Expand Up @@ -721,8 +721,8 @@ class Http2Stream : public AsyncWrap,
Statistics statistics_ = {};

private:
Http2Session* session_; // The Parent HTTP/2 Session
int32_t id_; // The Stream Identifier
Http2Session* session_ = nullptr; // The Parent HTTP/2 Session
int32_t id_ = 0; // The Stream Identifier
int32_t code_ = NGHTTP2_NO_ERROR; // The RST_STREAM code (if any)
int flags_ = NGHTTP2_STREAM_FLAG_NONE; // Internal state flags

Expand Down

0 comments on commit 828159f

Please sign in to comment.