Skip to content
This repository was archived by the owner on Aug 11, 2020. It is now read-only.

Commit c521620

Browse files
committed
[Squash] nits
1 parent 96a8113 commit c521620

7 files changed

+43
-47
lines changed

src/quic/node_quic_default_application.cc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ int DefaultApplication::GetStreamData(StreamData* stream_data) {
124124
&stream_data->count,
125125
MAX_VECTOR_COUNT);
126126

127-
stream_data->user_data = stream;
127+
stream_data->stream.reset(stream);
128128
stream_data->id = stream->id();
129129
stream_data->fin = stream->is_writable() ? 0 : 1;
130130

@@ -133,7 +133,7 @@ int DefaultApplication::GetStreamData(StreamData* stream_data) {
133133
// that yet as it depends entirely on how much data actually gets
134134
// serialized by ngtcp2.
135135
if (stream_data->count > 0)
136-
ScheduleStream(stream->id());
136+
stream->Schedule(&stream_queue_);
137137

138138
Debug(session(), "Selected %" PRId64 " buffers for stream %" PRId64 "%s",
139139
stream_data->count,
@@ -145,20 +145,18 @@ int DefaultApplication::GetStreamData(StreamData* stream_data) {
145145
bool DefaultApplication::StreamCommit(
146146
StreamData* stream_data,
147147
size_t datalen) {
148-
QuicStream* stream = static_cast<QuicStream*>(stream_data->user_data);
149-
CHECK_NOT_NULL(stream);
148+
CHECK(stream_data->stream);
150149
stream_data->remaining -= datalen;
151150
Consume(&stream_data->buf, &stream_data->count, datalen);
152-
stream->Commit(datalen);
151+
stream_data->stream->Commit(datalen);
153152
return true;
154153
}
155154

156155
bool DefaultApplication::ShouldSetFin(const StreamData& stream_data) {
157-
if (stream_data.user_data == nullptr ||
156+
if (!stream_data.stream ||
158157
!IsEmpty(stream_data.buf, stream_data.count))
159158
return false;
160-
QuicStream* stream = static_cast<QuicStream*>(stream_data.user_data);
161-
return !stream->is_writable();
159+
return !stream_data.stream->is_writable();
162160
}
163161

164162
} // namespace quic

src/quic/node_quic_session-inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ ssize_t QuicApplication::WriteVStream(
149149
uint8_t* buf,
150150
ssize_t* ndatalen,
151151
const StreamData& stream_data) {
152-
CHECK_LE(stream_data.count, 16);
152+
CHECK_LE(stream_data.count, MAX_VECTOR_COUNT);
153153
return ngtcp2_conn_writev_stream(
154154
session()->connection(),
155155
&path->path,

src/quic/node_quic_session.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ void QuicApplication::Acknowledge(
11111111

11121112
bool QuicApplication::SendPendingData() {
11131113
// The maximum number of packets to send per call
1114-
static constexpr size_t MAX_PACKETS = 16;
1114+
static constexpr size_t kMaxPackets = 16;
11151115
QuicPathStorage path;
11161116
std::unique_ptr<QuicPacket> packet;
11171117
uint8_t* pos = nullptr;
@@ -1190,7 +1190,7 @@ bool QuicApplication::SendPendingData() {
11901190
packet.reset();
11911191
pos = nullptr;
11921192
MaybeSetFin(stream_data);
1193-
if (++packets_sent == MAX_PACKETS)
1193+
if (++packets_sent == kMaxPackets)
11941194
break;
11951195
}
11961196
return true;

src/quic/node_quic_session.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,7 @@ class QuicApplication : public MemoryRetainer {
548548
int fin = 0;
549549
ngtcp2_vec data[MAX_VECTOR_COUNT] {};
550550
ngtcp2_vec* buf = nullptr;
551-
void* user_data = nullptr;
552-
uint8_t* pos = nullptr;
551+
BaseObjectPtr<QuicStream> stream;
553552
StreamData() { buf = data; }
554553
};
555554

src/quic/node_quic_stream-inl.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,6 @@ bool QuicStream::is_read_paused() const {
7575
return flags_ & QUICSTREAM_FLAG_READ_PAUSED;
7676
}
7777

78-
bool QuicStream::IsAlive() {
79-
return !is_destroyed() && !IsClosing();
80-
}
81-
82-
bool QuicStream::IsClosing() {
83-
return !is_writable() && !is_readable();
84-
}
85-
8678
void QuicStream::set_fin_sent() {
8779
CHECK(!is_writable());
8880
flags_ |= QUICSTREAM_FLAG_FIN_SENT;
@@ -168,26 +160,6 @@ void QuicStream::Commit(ssize_t amount) {
168160
streambuf_.Seek(amount);
169161
}
170162

171-
int QuicStream::ReadStart() {
172-
CHECK(!is_destroyed());
173-
CHECK(is_readable());
174-
set_read_start();
175-
set_read_resume();
176-
IncrementStat(
177-
inbound_consumed_data_while_paused_,
178-
&stream_stats_,
179-
&stream_stats::max_offset);
180-
session_->ExtendStreamOffset(this, inbound_consumed_data_while_paused_);
181-
return 0;
182-
}
183-
184-
int QuicStream::ReadStop() {
185-
CHECK(!is_destroyed());
186-
CHECK(is_readable());
187-
set_read_pause();
188-
return 0;
189-
}
190-
191163
void QuicStream::ResetStream(uint64_t app_error_code) {
192164
// On calling shutdown, the stream will no longer be
193165
// readable or writable, all any pending data in the

src/quic/node_quic_stream.cc

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,7 @@ int QuicStream::DoShutdown(ShutdownWrap* req_wrap) {
203203
session()->ResumeStream(stream_id_);
204204
}
205205

206-
req_wrap->Done(0);
207-
return 0;
206+
return 1;
208207
}
209208

210209
int QuicStream::DoWrite(
@@ -265,6 +264,34 @@ int QuicStream::DoWrite(
265264
return 0;
266265
}
267266

267+
bool QuicStream::IsAlive() {
268+
return !is_destroyed() && !IsClosing();
269+
}
270+
271+
bool QuicStream::IsClosing() {
272+
return !is_writable() && !is_readable();
273+
}
274+
275+
int QuicStream::ReadStart() {
276+
CHECK(!is_destroyed());
277+
CHECK(is_readable());
278+
set_read_start();
279+
set_read_resume();
280+
IncrementStat(
281+
inbound_consumed_data_while_paused_,
282+
&stream_stats_,
283+
&stream_stats::max_offset);
284+
session_->ExtendStreamOffset(this, inbound_consumed_data_while_paused_);
285+
return 0;
286+
}
287+
288+
int QuicStream::ReadStop() {
289+
CHECK(!is_destroyed());
290+
CHECK(is_readable());
291+
set_read_pause();
292+
return 0;
293+
}
294+
268295
void QuicStream::IncrementStats(size_t datalen) {
269296
uint64_t len = static_cast<uint64_t>(datalen);
270297
IncrementStat(len, &stream_stats_, &stream_stats::bytes_received);

src/quic/node_quic_stream.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,10 @@ class QuicStream : public AsyncWrap, public StreamBase {
341341
inline bool SubmitTrailers(v8::Local<v8::Array> headers);
342342

343343
// Required for StreamBase
344-
inline bool IsAlive() override;
345-
inline bool IsClosing() override;
346-
inline int ReadStart() override;
347-
inline int ReadStop() override;
344+
bool IsAlive() override;
345+
bool IsClosing() override;
346+
int ReadStart() override;
347+
int ReadStop() override;
348348
int DoShutdown(ShutdownWrap* req_wrap) override;
349349

350350
AsyncWrap* GetAsyncWrap() override { return this; }

0 commit comments

Comments
 (0)