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

Commit

Permalink
[Squash] nits
Browse files Browse the repository at this point in the history
  • Loading branch information
jasnell committed Jan 9, 2020
1 parent 96a8113 commit c521620
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 47 deletions.
14 changes: 6 additions & 8 deletions src/quic/node_quic_default_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ int DefaultApplication::GetStreamData(StreamData* stream_data) {
&stream_data->count,
MAX_VECTOR_COUNT);

stream_data->user_data = stream;
stream_data->stream.reset(stream);
stream_data->id = stream->id();
stream_data->fin = stream->is_writable() ? 0 : 1;

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

Debug(session(), "Selected %" PRId64 " buffers for stream %" PRId64 "%s",
stream_data->count,
Expand All @@ -145,20 +145,18 @@ int DefaultApplication::GetStreamData(StreamData* stream_data) {
bool DefaultApplication::StreamCommit(
StreamData* stream_data,
size_t datalen) {
QuicStream* stream = static_cast<QuicStream*>(stream_data->user_data);
CHECK_NOT_NULL(stream);
CHECK(stream_data->stream);
stream_data->remaining -= datalen;
Consume(&stream_data->buf, &stream_data->count, datalen);
stream->Commit(datalen);
stream_data->stream->Commit(datalen);
return true;
}

bool DefaultApplication::ShouldSetFin(const StreamData& stream_data) {
if (stream_data.user_data == nullptr ||
if (!stream_data.stream ||
!IsEmpty(stream_data.buf, stream_data.count))
return false;
QuicStream* stream = static_cast<QuicStream*>(stream_data.user_data);
return !stream->is_writable();
return !stream_data.stream->is_writable();
}

} // namespace quic
Expand Down
2 changes: 1 addition & 1 deletion src/quic/node_quic_session-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ ssize_t QuicApplication::WriteVStream(
uint8_t* buf,
ssize_t* ndatalen,
const StreamData& stream_data) {
CHECK_LE(stream_data.count, 16);
CHECK_LE(stream_data.count, MAX_VECTOR_COUNT);
return ngtcp2_conn_writev_stream(
session()->connection(),
&path->path,
Expand Down
4 changes: 2 additions & 2 deletions src/quic/node_quic_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ void QuicApplication::Acknowledge(

bool QuicApplication::SendPendingData() {
// The maximum number of packets to send per call
static constexpr size_t MAX_PACKETS = 16;
static constexpr size_t kMaxPackets = 16;
QuicPathStorage path;
std::unique_ptr<QuicPacket> packet;
uint8_t* pos = nullptr;
Expand Down Expand Up @@ -1190,7 +1190,7 @@ bool QuicApplication::SendPendingData() {
packet.reset();
pos = nullptr;
MaybeSetFin(stream_data);
if (++packets_sent == MAX_PACKETS)
if (++packets_sent == kMaxPackets)
break;
}
return true;
Expand Down
3 changes: 1 addition & 2 deletions src/quic/node_quic_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,7 @@ class QuicApplication : public MemoryRetainer {
int fin = 0;
ngtcp2_vec data[MAX_VECTOR_COUNT] {};
ngtcp2_vec* buf = nullptr;
void* user_data = nullptr;
uint8_t* pos = nullptr;
BaseObjectPtr<QuicStream> stream;
StreamData() { buf = data; }
};

Expand Down
28 changes: 0 additions & 28 deletions src/quic/node_quic_stream-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,6 @@ bool QuicStream::is_read_paused() const {
return flags_ & QUICSTREAM_FLAG_READ_PAUSED;
}

bool QuicStream::IsAlive() {
return !is_destroyed() && !IsClosing();
}

bool QuicStream::IsClosing() {
return !is_writable() && !is_readable();
}

void QuicStream::set_fin_sent() {
CHECK(!is_writable());
flags_ |= QUICSTREAM_FLAG_FIN_SENT;
Expand Down Expand Up @@ -168,26 +160,6 @@ void QuicStream::Commit(ssize_t amount) {
streambuf_.Seek(amount);
}

int QuicStream::ReadStart() {
CHECK(!is_destroyed());
CHECK(is_readable());
set_read_start();
set_read_resume();
IncrementStat(
inbound_consumed_data_while_paused_,
&stream_stats_,
&stream_stats::max_offset);
session_->ExtendStreamOffset(this, inbound_consumed_data_while_paused_);
return 0;
}

int QuicStream::ReadStop() {
CHECK(!is_destroyed());
CHECK(is_readable());
set_read_pause();
return 0;
}

void QuicStream::ResetStream(uint64_t app_error_code) {
// On calling shutdown, the stream will no longer be
// readable or writable, all any pending data in the
Expand Down
31 changes: 29 additions & 2 deletions src/quic/node_quic_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ int QuicStream::DoShutdown(ShutdownWrap* req_wrap) {
session()->ResumeStream(stream_id_);
}

req_wrap->Done(0);
return 0;
return 1;
}

int QuicStream::DoWrite(
Expand Down Expand Up @@ -265,6 +264,34 @@ int QuicStream::DoWrite(
return 0;
}

bool QuicStream::IsAlive() {
return !is_destroyed() && !IsClosing();
}

bool QuicStream::IsClosing() {
return !is_writable() && !is_readable();
}

int QuicStream::ReadStart() {
CHECK(!is_destroyed());
CHECK(is_readable());
set_read_start();
set_read_resume();
IncrementStat(
inbound_consumed_data_while_paused_,
&stream_stats_,
&stream_stats::max_offset);
session_->ExtendStreamOffset(this, inbound_consumed_data_while_paused_);
return 0;
}

int QuicStream::ReadStop() {
CHECK(!is_destroyed());
CHECK(is_readable());
set_read_pause();
return 0;
}

void QuicStream::IncrementStats(size_t datalen) {
uint64_t len = static_cast<uint64_t>(datalen);
IncrementStat(len, &stream_stats_, &stream_stats::bytes_received);
Expand Down
8 changes: 4 additions & 4 deletions src/quic/node_quic_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ class QuicStream : public AsyncWrap, public StreamBase {
inline bool SubmitTrailers(v8::Local<v8::Array> headers);

// Required for StreamBase
inline bool IsAlive() override;
inline bool IsClosing() override;
inline int ReadStart() override;
inline int ReadStop() override;
bool IsAlive() override;
bool IsClosing() override;
int ReadStart() override;
int ReadStop() override;
int DoShutdown(ShutdownWrap* req_wrap) override;

AsyncWrap* GetAsyncWrap() override { return this; }
Expand Down

0 comments on commit c521620

Please sign in to comment.