Skip to content

Commit

Permalink
h2load: Fix bug that ttfb is not recorded if h3 stream has no data
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsuhiro-t committed Dec 27, 2023
1 parent 7209bff commit 04a14ee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/h2load_http3_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,23 @@ int Http3Session::stream_close(int64_t stream_id, uint64_t app_error_code) {
return 0;
}

namespace {
int end_stream(nghttp3_conn *conn, int64_t stream_id, void *user_data,
void *stream_user_data) {
auto s = static_cast<Http3Session *>(user_data);
if (s->end_stream(stream_id) != 0) {
return NGHTTP3_ERR_CALLBACK_FAILURE;
}
return 0;
}
} // namespace

int Http3Session::end_stream(int64_t stream_id) {
client_->record_ttfb();

return 0;
}

namespace {
int recv_data(nghttp3_conn *conn, int64_t stream_id, const uint8_t *data,
size_t datalen, void *user_data, void *stream_user_data) {
Expand Down Expand Up @@ -321,7 +338,7 @@ int Http3Session::init_conn() {
h2load::recv_header,
nullptr, // end_trailers
h2load::stop_sending,
nullptr, // end_stream
h2load::end_stream,
h2load::reset_stream,
nullptr, // shutdown
};
Expand Down
1 change: 1 addition & 0 deletions src/h2load_http3_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Http3Session : public Session {

int init_conn();
int stream_close(int64_t stream_id, uint64_t app_error_code);
int end_stream(int64_t stream_id);
void recv_data(int64_t stream_id, const uint8_t *data, size_t datalen);
void consume(int64_t stream_id, size_t nconsumed);
void begin_headers(int64_t stream_id);
Expand Down

0 comments on commit 04a14ee

Please sign in to comment.