Merge pull request #1766 from nghttp2/h2load-h3-reset-stream-cb

h2load: Implement nghttp3 reset_stream callback
This commit is contained in:
Tatsuhiro Tsujikawa 2022-07-26 17:39:58 +09:00 committed by GitHub
commit a3be763650
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View File

@ -234,6 +234,28 @@ int Http3Session::stop_sending(int64_t stream_id, uint64_t app_error_code) {
return 0;
}
namespace {
int reset_stream(nghttp3_conn *conn, int64_t stream_id, uint64_t app_error_code,
void *user_data, void *stream_user_data) {
auto s = static_cast<Http3Session *>(user_data);
if (s->reset_stream(stream_id, app_error_code) != 0) {
return NGHTTP3_ERR_CALLBACK_FAILURE;
}
return 0;
}
} // namespace
int Http3Session::reset_stream(int64_t stream_id, uint64_t app_error_code) {
auto rv = ngtcp2_conn_shutdown_stream_write(client_->quic.conn, stream_id,
app_error_code);
if (rv != 0) {
std::cerr << "ngtcp2_conn_shutdown_stream_write: " << ngtcp2_strerror(rv)
<< std::endl;
return -1;
}
return 0;
}
int Http3Session::close_stream(int64_t stream_id, uint64_t app_error_code) {
auto rv = nghttp3_conn_close_stream(conn_, stream_id, app_error_code);
switch (rv) {
@ -299,6 +321,9 @@ int Http3Session::init_conn() {
h2load::recv_header,
nullptr, // end_trailers
h2load::stop_sending,
nullptr, // end_stream
h2load::reset_stream,
nullptr, // shutdown
};
auto config = client_->worker->config;

View File

@ -52,6 +52,7 @@ public:
void recv_header(int64_t stream_id, const nghttp3_vec *name,
const nghttp3_vec *value);
int stop_sending(int64_t stream_id, uint64_t app_error_code);
int reset_stream(int64_t stream_id, uint64_t app_error_code);
int close_stream(int64_t stream_id, uint64_t app_error_code);
int shutdown_stream_read(int64_t stream_id);