Skip to content

Commit

Permalink
http2: rename some nghttp2 stream flags
Browse files Browse the repository at this point in the history
This change makes NGHTTP2_STREAM_* enum values consistent. It also
resolves a collision between enum values defined in
nghttp2_error_code and nghttp2_stream_flags.

PR-URL: #14637
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
kjin authored and jasnell committed Aug 8, 2017
1 parent 611851d commit 1e33f92
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions src/node_http2_core-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ inline void Nghttp2Stream::Destroy() {
// Do nothing if this stream instance is already destroyed
if (IsDestroyed())
return;
flags_ |= NGHTTP2_STREAM_DESTROYED;
flags_ |= NGHTTP2_STREAM_FLAG_DESTROYED;
Nghttp2Session* session = this->session_;

if (session != nullptr) {
Expand Down Expand Up @@ -539,8 +539,8 @@ inline void Nghttp2Stream::ReadStart() {
id_,
prev_local_window_size_);
}
flags_ |= NGHTTP2_STREAM_READ_START;
flags_ &= ~NGHTTP2_STREAM_READ_PAUSED;
flags_ |= NGHTTP2_STREAM_FLAG_READ_START;
flags_ &= ~NGHTTP2_STREAM_FLAG_READ_PAUSED;

// Flush any queued data chunks immediately out to the JS layer
FlushDataChunks();
Expand All @@ -549,11 +549,11 @@ inline void Nghttp2Stream::ReadStart() {
inline void Nghttp2Stream::ReadStop() {
DEBUG_HTTP2("Nghttp2Stream %d: stop reading\n", id_);
// Has no effect if IsReading() is false, which will happen if we either
// have not started reading yet at all (NGHTTP2_STREAM_READ_START is not
// set) or if we're already paused (NGHTTP2_STREAM_READ_PAUSED is set.
// have not started reading yet at all (NGHTTP2_STREAM_FLAG_READ_START is not
// set) or if we're already paused (NGHTTP2_STREAM_FLAG_READ_PAUSED is set.
if (!IsReading())
return;
flags_ |= NGHTTP2_STREAM_READ_PAUSED;
flags_ |= NGHTTP2_STREAM_FLAG_READ_PAUSED;

// When not reading, explicitly set the local window size to 0 so that
// the peer does not keep sending data that has to be buffered
Expand Down
24 changes: 12 additions & 12 deletions src/node_http2_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ enum nghttp2_stream_flags {
// Writable side has ended
NGHTTP2_STREAM_FLAG_SHUT = 0x1,
// Reading has started
NGHTTP2_STREAM_READ_START = 0x2,
NGHTTP2_STREAM_FLAG_READ_START = 0x2,
// Reading is paused
NGHTTP2_STREAM_READ_PAUSED = 0x4,
NGHTTP2_STREAM_FLAG_READ_PAUSED = 0x4,
// Stream is closed
NGHTTP2_STREAM_CLOSED = 0x8,
NGHTTP2_STREAM_FLAG_CLOSED = 0x8,
// Stream is destroyed
NGHTTP2_STREAM_DESTROYED = 0x10
NGHTTP2_STREAM_FLAG_DESTROYED = 0x10
};


Expand Down Expand Up @@ -301,7 +301,7 @@ class Nghttp2Stream {

// Returns true if this stream has been destroyed
inline bool IsDestroyed() const {
return flags_ & NGHTTP2_STREAM_DESTROYED;
return flags_ & NGHTTP2_STREAM_FLAG_DESTROYED;
}

// Queue outbound chunks of data to be sent on this stream
Expand Down Expand Up @@ -361,24 +361,24 @@ class Nghttp2Stream {

// Returns true if reading is paused
inline bool IsPaused() const {
return flags_ & NGHTTP2_STREAM_READ_PAUSED;
return flags_ & NGHTTP2_STREAM_FLAG_READ_PAUSED;
}

inline bool GetTrailers() const {
return getTrailers_;
}

// Returns true if this stream is in the reading state, which occurs when
// the NGHTTP2_STREAM_READ_START flag has been set and the
// NGHTTP2_STREAM_READ_PAUSED flag is *not* set.
// the NGHTTP2_STREAM_FLAG_READ_START flag has been set and the
// NGHTTP2_STREAM_FLAG_READ_PAUSED flag is *not* set.
inline bool IsReading() const {
return flags_ & NGHTTP2_STREAM_READ_START &&
!(flags_ & NGHTTP2_STREAM_READ_PAUSED);
return flags_ & NGHTTP2_STREAM_FLAG_READ_START &&
!(flags_ & NGHTTP2_STREAM_FLAG_READ_PAUSED);
}

inline void Close(int32_t code) {
DEBUG_HTTP2("Nghttp2Stream %d: closing with code %d\n", id_, code);
flags_ |= NGHTTP2_STREAM_CLOSED;
flags_ |= NGHTTP2_STREAM_FLAG_CLOSED;
code_ = code;
session_->OnStreamClose(id_, code);
DEBUG_HTTP2("Nghttp2Stream %d: closed\n", id_);
Expand All @@ -387,7 +387,7 @@ class Nghttp2Stream {
// Returns true if this stream has been closed either by receiving or
// sending an RST_STREAM frame.
inline bool IsClosed() const {
return flags_ & NGHTTP2_STREAM_CLOSED;
return flags_ & NGHTTP2_STREAM_FLAG_CLOSED;
}

// Returns the RST_STREAM code used to close this stream
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http2-binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ const expectedNGConstants = {
NGHTTP2_INTERNAL_ERROR: 2,
NGHTTP2_FLOW_CONTROL_ERROR: 3,
NGHTTP2_SETTINGS_TIMEOUT: 4,
NGHTTP2_STREAM_CLOSED: 8,
NGHTTP2_STREAM_CLOSED: 5,
NGHTTP2_FRAME_SIZE_ERROR: 6,
NGHTTP2_REFUSED_STREAM: 7,
NGHTTP2_CANCEL: 8,
Expand Down

0 comments on commit 1e33f92

Please sign in to comment.