Skip to content

Commit

Permalink
quic: use qlog fin flag
Browse files Browse the repository at this point in the history
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: #34752
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
jasnell committed Aug 21, 2020
1 parent 2a80737 commit 44e6a6a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions src/quic/node_quic_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3608,8 +3608,9 @@ void QuicSession::OnQlogWrite(
std::vector<uint8_t> buffer(len);
memcpy(buffer.data(), data, len);
env->SetImmediate([ptr = std::move(ptr),
buffer = std::move(buffer)](Environment*) {
ptr->Emit(buffer.data(), buffer.size());
buffer = std::move(buffer),
flags](Environment*) {
ptr->Emit(buffer.data(), buffer.size(), flags);
});
}

Expand Down Expand Up @@ -3647,7 +3648,7 @@ QLogStream::QLogStream(Environment* env, v8::Local<Object> obj)
StreamBase::AttachToObject(GetObject());
}

void QLogStream::Emit(const uint8_t* data, size_t len) {
void QLogStream::Emit(const uint8_t* data, size_t len, uint32_t flags) {
size_t remaining = len;
while (remaining != 0) {
uv_buf_t buf = EmitAlloc(len);
Expand All @@ -3658,10 +3659,7 @@ void QLogStream::Emit(const uint8_t* data, size_t len) {
EmitRead(avail, buf);
}

// The last chunk that ngtcp2 writes is 6 bytes. Unfortunately,
// this is the only way for us to know that ngtcp2 is definitely
// done sending qlog events.
if (ended_ && len == 6)
if (ended_ && flags & NGTCP2_QLOG_WRITE_FLAG_FIN)
EmitRead(UV_EOF);
}

Expand Down
2 changes: 1 addition & 1 deletion src/quic/node_quic_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class QLogStream final : public AsyncWrap,

QLogStream(Environment* env, v8::Local<v8::Object> obj);

void Emit(const uint8_t* data, size_t len);
void Emit(const uint8_t* data, size_t len, uint32_t flags);

void End() { ended_ = true; }

Expand Down

0 comments on commit 44e6a6a

Please sign in to comment.