Add missing acked_stream_data_offset callback

This commit is contained in:
Tatsuhiro Tsujikawa 2019-08-31 17:33:11 +09:00
parent 2da0db70de
commit 33d2a93294
4 changed files with 32 additions and 1 deletions

View File

@ -461,6 +461,7 @@ struct Client {
int quic_handshake_completed();
int quic_recv_stream_data(int64_t stream_id, int fin, const uint8_t *data,
size_t datalen);
int quic_acked_stream_data_offset(int64_t stream_id, size_t datalen);
int quic_stream_close(int64_t stream_id, uint64_t app_error_code);
int quic_stream_reset(int64_t stream_id, uint64_t app_error_code);
int quic_extend_max_local_streams();

View File

@ -373,4 +373,13 @@ int Http3Session::add_write_offset(int64_t stream_id, size_t ndatalen) {
return 0;
}
int Http3Session::add_ack_offset(int64_t stream_id, size_t datalen) {
auto rv = nghttp3_conn_add_ack_offset(conn_, stream_id, datalen);
if (rv != 0) {
client_->quic.last_error = quic::err_application(rv);
return -1;
}
return 0;
}
} // namespace h2load

View File

@ -64,6 +64,7 @@ public:
size_t veccnt);
int block_stream(int64_t stream_id);
int add_write_offset(int64_t stream_id, size_t ndatalen);
int add_ack_offset(int64_t stream_id, size_t datalen);
private:
Client *client_;

View File

@ -126,6 +126,26 @@ int Client::quic_recv_stream_data(int64_t stream_id, int fin,
return 0;
}
namespace {
int acked_stream_data_offset(ngtcp2_conn *conn, int64_t stream_id,
uint64_t offset, size_t datalen, void *user_data,
void *stream_user_data) {
auto c = static_cast<Client *>(user_data);
if (c->quic_acked_stream_data_offset(stream_id, datalen) != 0) {
return NGTCP2_ERR_CALLBACK_FAILURE;
}
return 0;
}
} // namespace
int Client::quic_acked_stream_data_offset(int64_t stream_id, size_t datalen) {
auto s = static_cast<Http3Session *>(session.get());
if (s->add_ack_offset(stream_id, datalen) != 0) {
return -1;
}
return 0;
}
namespace {
int stream_close(ngtcp2_conn *conn, int64_t stream_id, uint64_t app_error_code,
void *user_data, void *stream_user_data) {
@ -331,7 +351,7 @@ int Client::quic_init(const sockaddr *local_addr, socklen_t local_addrlen,
ngtcp2_crypto_hp_mask_cb,
h2load::recv_stream_data,
nullptr, // acked_crypto_offset
nullptr, // acked_stream_data_offset
h2load::acked_stream_data_offset,
nullptr, // stream_open
h2load::stream_close,
nullptr, // recv_stateless_reset