Skip to content

Commit 1e33f92

Browse files
kjinjasnell
authored andcommitted
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: #14637 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 611851d commit 1e33f92

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

src/node_http2_core-inl.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ inline void Nghttp2Stream::Destroy() {
314314
// Do nothing if this stream instance is already destroyed
315315
if (IsDestroyed())
316316
return;
317-
flags_ |= NGHTTP2_STREAM_DESTROYED;
317+
flags_ |= NGHTTP2_STREAM_FLAG_DESTROYED;
318318
Nghttp2Session* session = this->session_;
319319

320320
if (session != nullptr) {
@@ -539,8 +539,8 @@ inline void Nghttp2Stream::ReadStart() {
539539
id_,
540540
prev_local_window_size_);
541541
}
542-
flags_ |= NGHTTP2_STREAM_READ_START;
543-
flags_ &= ~NGHTTP2_STREAM_READ_PAUSED;
542+
flags_ |= NGHTTP2_STREAM_FLAG_READ_START;
543+
flags_ &= ~NGHTTP2_STREAM_FLAG_READ_PAUSED;
544544

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

558558
// When not reading, explicitly set the local window size to 0 so that
559559
// the peer does not keep sending data that has to be buffered

src/node_http2_core.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ enum nghttp2_stream_flags {
5959
// Writable side has ended
6060
NGHTTP2_STREAM_FLAG_SHUT = 0x1,
6161
// Reading has started
62-
NGHTTP2_STREAM_READ_START = 0x2,
62+
NGHTTP2_STREAM_FLAG_READ_START = 0x2,
6363
// Reading is paused
64-
NGHTTP2_STREAM_READ_PAUSED = 0x4,
64+
NGHTTP2_STREAM_FLAG_READ_PAUSED = 0x4,
6565
// Stream is closed
66-
NGHTTP2_STREAM_CLOSED = 0x8,
66+
NGHTTP2_STREAM_FLAG_CLOSED = 0x8,
6767
// Stream is destroyed
68-
NGHTTP2_STREAM_DESTROYED = 0x10
68+
NGHTTP2_STREAM_FLAG_DESTROYED = 0x10
6969
};
7070

7171

@@ -301,7 +301,7 @@ class Nghttp2Stream {
301301

302302
// Returns true if this stream has been destroyed
303303
inline bool IsDestroyed() const {
304-
return flags_ & NGHTTP2_STREAM_DESTROYED;
304+
return flags_ & NGHTTP2_STREAM_FLAG_DESTROYED;
305305
}
306306

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

362362
// Returns true if reading is paused
363363
inline bool IsPaused() const {
364-
return flags_ & NGHTTP2_STREAM_READ_PAUSED;
364+
return flags_ & NGHTTP2_STREAM_FLAG_READ_PAUSED;
365365
}
366366

367367
inline bool GetTrailers() const {
368368
return getTrailers_;
369369
}
370370

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

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

393393
// Returns the RST_STREAM code used to close this stream

test/parallel/test-http2-binding.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ const expectedNGConstants = {
175175
NGHTTP2_INTERNAL_ERROR: 2,
176176
NGHTTP2_FLOW_CONTROL_ERROR: 3,
177177
NGHTTP2_SETTINGS_TIMEOUT: 4,
178-
NGHTTP2_STREAM_CLOSED: 8,
178+
NGHTTP2_STREAM_CLOSED: 5,
179179
NGHTTP2_FRAME_SIZE_ERROR: 6,
180180
NGHTTP2_REFUSED_STREAM: 7,
181181
NGHTTP2_CANCEL: 8,

0 commit comments

Comments
 (0)