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
Expand Up @@ -314,7 +314,7 @@ inline void Nghttp2Stream::Destroy() {
// Do nothing if this stream instance is already destroyed // Do nothing if this stream instance is already destroyed
if (IsDestroyed()) if (IsDestroyed())
return; return;
flags_ |= NGHTTP2_STREAM_DESTROYED; flags_ |= NGHTTP2_STREAM_FLAG_DESTROYED;
Nghttp2Session* session = this->session_; Nghttp2Session* session = this->session_;


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


// Flush any queued data chunks immediately out to the JS layer // Flush any queued data chunks immediately out to the JS layer
FlushDataChunks(); FlushDataChunks();
Expand All @@ -549,11 +549,11 @@ inline void Nghttp2Stream::ReadStart() {
inline void Nghttp2Stream::ReadStop() { inline void Nghttp2Stream::ReadStop() {
DEBUG_HTTP2("Nghttp2Stream %d: stop reading\n", id_); DEBUG_HTTP2("Nghttp2Stream %d: stop reading\n", id_);
// Has no effect if IsReading() is false, which will happen if we either // 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 // have not started reading yet at all (NGHTTP2_STREAM_FLAG_READ_START is not
// set) or if we're already paused (NGHTTP2_STREAM_READ_PAUSED is set. // set) or if we're already paused (NGHTTP2_STREAM_FLAG_READ_PAUSED is set.
if (!IsReading()) if (!IsReading())
return; 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 // 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 // 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
Expand Up @@ -59,13 +59,13 @@ enum nghttp2_stream_flags {
// Writable side has ended // Writable side has ended
NGHTTP2_STREAM_FLAG_SHUT = 0x1, NGHTTP2_STREAM_FLAG_SHUT = 0x1,
// Reading has started // Reading has started
NGHTTP2_STREAM_READ_START = 0x2, NGHTTP2_STREAM_FLAG_READ_START = 0x2,
// Reading is paused // Reading is paused
NGHTTP2_STREAM_READ_PAUSED = 0x4, NGHTTP2_STREAM_FLAG_READ_PAUSED = 0x4,
// Stream is closed // Stream is closed
NGHTTP2_STREAM_CLOSED = 0x8, NGHTTP2_STREAM_FLAG_CLOSED = 0x8,
// Stream is destroyed // 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 // Returns true if this stream has been destroyed
inline bool IsDestroyed() const { 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 // 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 // Returns true if reading is paused
inline bool IsPaused() const { inline bool IsPaused() const {
return flags_ & NGHTTP2_STREAM_READ_PAUSED; return flags_ & NGHTTP2_STREAM_FLAG_READ_PAUSED;
} }


inline bool GetTrailers() const { inline bool GetTrailers() const {
return getTrailers_; return getTrailers_;
} }


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


inline void Close(int32_t code) { inline void Close(int32_t code) {
DEBUG_HTTP2("Nghttp2Stream %d: closing with code %d\n", id_, code); DEBUG_HTTP2("Nghttp2Stream %d: closing with code %d\n", id_, code);
flags_ |= NGHTTP2_STREAM_CLOSED; flags_ |= NGHTTP2_STREAM_FLAG_CLOSED;
code_ = code; code_ = code;
session_->OnStreamClose(id_, code); session_->OnStreamClose(id_, code);
DEBUG_HTTP2("Nghttp2Stream %d: closed\n", id_); 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 // Returns true if this stream has been closed either by receiving or
// sending an RST_STREAM frame. // sending an RST_STREAM frame.
inline bool IsClosed() const { 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 // Returns the RST_STREAM code used to close this stream
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http2-binding.js
Expand Up @@ -175,7 +175,7 @@ const expectedNGConstants = {
NGHTTP2_INTERNAL_ERROR: 2, NGHTTP2_INTERNAL_ERROR: 2,
NGHTTP2_FLOW_CONTROL_ERROR: 3, NGHTTP2_FLOW_CONTROL_ERROR: 3,
NGHTTP2_SETTINGS_TIMEOUT: 4, NGHTTP2_SETTINGS_TIMEOUT: 4,
NGHTTP2_STREAM_CLOSED: 8, NGHTTP2_STREAM_CLOSED: 5,
NGHTTP2_FRAME_SIZE_ERROR: 6, NGHTTP2_FRAME_SIZE_ERROR: 6,
NGHTTP2_REFUSED_STREAM: 7, NGHTTP2_REFUSED_STREAM: 7,
NGHTTP2_CANCEL: 8, NGHTTP2_CANCEL: 8,
Expand Down

0 comments on commit 1e33f92

Please sign in to comment.