Skip to content
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.

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

http2: cleanup and refactoring of http2 internals #32884

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/node_http2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ using v8::Integer;
using v8::Isolate;
using v8::Local;
using v8::MaybeLocal;
using v8::NewStringType;
using v8::Number;
using v8::Object;
using v8::ObjectTemplate;
Expand Down Expand Up @@ -204,7 +203,7 @@ Http2Options::Http2Options(Http2State* http2_state, SessionType type) {
uint32_t val = buffer[IDX_SETTINGS_ ## name]; \
entries[count++] = \
nghttp2_settings_entry {NGHTTP2_SETTINGS_ ## name, val}; \
} } while(0)
} } while (0)
jasnell marked this conversation as resolved.
Show resolved Hide resolved

size_t Http2Settings::Init(
Http2State* http2_state,
Expand Down Expand Up @@ -280,7 +279,6 @@ void Http2Settings::Update(Http2Session* session, get_setting fn) {
fn(session->session(), NGHTTP2_SETTINGS_ ## name);
HTTP2_SETTINGS(V)
#undef V

}

// Initializes the shared TypedArray with the default settings values.
Expand Down Expand Up @@ -1933,7 +1931,7 @@ void Http2Stream::Destroy() {
// Do nothing if this stream instance is already destroyed
if (is_destroyed())
return;
if (session_->HasPendingRstStream(id_))
if (session_->has_pending_rststream(id_))
FlushRstStream();
set_destroyed();

Expand Down Expand Up @@ -3050,7 +3048,7 @@ void Initialize(Local<Object> target,
#define V(name) FIXED_ONE_BYTE_STRING(isolate, #name),
Local<Value> error_code_names[] = {
HTTP2_ERROR_CODES(V)
Local<Value>() // Unused.
Local<Value>() // Unused.
};
#undef V

Expand Down
19 changes: 11 additions & 8 deletions src/node_http2.h
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,10 @@ class Http2Session : public AsyncWrap,
#define IS_FLAG(name, flag) \
bool is_##name() const { return flags_ & flag; } \
void set_##name(bool on = true) { \
if (on) flags_ |= flag; \
else flags_ &= ~flag; \
if (on) \
flags_ |= flag; \
else \
flags_ &= ~flag; \
}

IS_FLAG(in_scope, kSessionStateHasScope)
Expand Down Expand Up @@ -672,10 +674,11 @@ class Http2Session : public AsyncWrap,
pending_rst_streams_.emplace_back(stream_id);
}

bool HasPendingRstStream(int32_t stream_id) {
return pending_rst_streams_.end() != std::find(pending_rst_streams_.begin(),
pending_rst_streams_.end(),
stream_id);
bool has_pending_rststream(int32_t stream_id) {
return pending_rst_streams_.end() !=
std::find(pending_rst_streams_.begin(),
pending_rst_streams_.end(),
stream_id);
}

// Handle reads/writes from the underlying network transport.
Expand Down Expand Up @@ -1028,7 +1031,7 @@ class Http2Ping : public AsyncWrap {

private:
BaseObjectWeakPtr<Http2Session> session_;
v8::Persistent<v8::Function> callback_;
v8::Global<v8::Function> callback_;
uint64_t startTime_;
};

Expand Down Expand Up @@ -1074,7 +1077,7 @@ class Http2Settings : public AsyncWrap {
const nghttp2_settings_entry* entries);

BaseObjectWeakPtr<Http2Session> session_;
v8::Persistent<v8::Function> callback_;
v8::Global<v8::Function> callback_;
uint64_t startTime_;
size_t count_ = 0;
nghttp2_settings_entry entries_[IDX_SETTINGS_COUNT];
Expand Down