Browse Source

http2: rename some nghttp2 stream flags

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: https://github.com/nodejs/node/pull/14637
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
v6
Kelvin Jin 7 years ago
committed by James M Snell
parent
commit
1e33f92d6a
  1. 12
      src/node_http2_core-inl.h
  2. 24
      src/node_http2_core.h
  3. 2
      test/parallel/test-http2-binding.js

12
src/node_http2_core-inl.h

@ -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) {
@ -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();
@ -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

24
src/node_http2_core.h

@ -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
};
@ -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
@ -361,7 +361,7 @@ 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 {
@ -369,16 +369,16 @@ class Nghttp2Stream {
}
// 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_);
@ -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

2
test/parallel/test-http2-binding.js

@ -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,

Loading…
Cancel
Save