summaryrefslogtreecommitdiffstats
path: root/src/shrpx_http3_upstream.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 08:52:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 08:52:50 +0000
commit9752fb8037bf6856aad9c51a1a7370ffc866f201 (patch)
tree054ae5378aa8919e67fa610a348b5f4e8ef9de3b /src/shrpx_http3_upstream.cc
parentAdding upstream version 1.60.0. (diff)
downloadnghttp2-9752fb8037bf6856aad9c51a1a7370ffc866f201.tar.xz
nghttp2-9752fb8037bf6856aad9c51a1a7370ffc866f201.zip
Adding upstream version 1.61.0.upstream/1.61.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/shrpx_http3_upstream.cc')
-rw-r--r--src/shrpx_http3_upstream.cc47
1 files changed, 36 insertions, 11 deletions
diff --git a/src/shrpx_http3_upstream.cc b/src/shrpx_http3_upstream.cc
index b8667a3..d12d2da 100644
--- a/src/shrpx_http3_upstream.cc
+++ b/src/shrpx_http3_upstream.cc
@@ -118,7 +118,6 @@ Http3Upstream::Http3Upstream(ClientHandler *handler)
httpconn_{nullptr},
downstream_queue_{downstream_queue_size(handler->get_worker()),
!get_config()->http2_proxy},
- retry_close_{false},
tx_{
.data = std::unique_ptr<uint8_t[]>(new uint8_t[64_k]),
} {
@@ -212,8 +211,10 @@ int get_new_connection_id(ngtcp2_conn *conn, ngtcp2_cid *cid, uint8_t *token,
auto &qkms = conn_handler->get_quic_keying_materials();
auto &qkm = qkms->keying_materials.front();
- if (generate_quic_connection_id(*cid, cidlen, worker->get_cid_prefix(),
- qkm.id, qkm.cid_encryption_ctx) != 0) {
+ assert(SHRPX_QUIC_SCIDLEN == cidlen);
+
+ if (generate_quic_connection_id(*cid, worker->get_worker_id(), qkm.id,
+ qkm.cid_encryption_ctx) != 0) {
return NGTCP2_ERR_CALLBACK_FAILURE;
}
@@ -250,8 +251,9 @@ void Http3Upstream::http_begin_request_headers(int64_t stream_id) {
nghttp3_conn_set_stream_user_data(httpconn_, stream_id, downstream.get());
downstream->reset_upstream_rtimer();
+ downstream->repeat_header_timer();
- handler_->repeat_read_timer();
+ handler_->stop_read_timer();
auto &req = downstream->request();
req.http_major = 3;
@@ -609,8 +611,7 @@ int Http3Upstream::init(const UpstreamAddr *faddr, const Address &remote_addr,
ngtcp2_cid scid;
- if (generate_quic_connection_id(scid, SHRPX_QUIC_SCIDLEN,
- worker->get_cid_prefix(), qkm.id,
+ if (generate_quic_connection_id(scid, worker->get_worker_id(), qkm.id,
qkm.cid_encryption_ctx) != 0) {
return -1;
}
@@ -997,7 +998,18 @@ int Http3Upstream::write_streams() {
return 0;
}
-int Http3Upstream::on_timeout(Downstream *downstream) { return 0; }
+int Http3Upstream::on_timeout(Downstream *downstream) {
+ if (LOG_ENABLED(INFO)) {
+ ULOG(INFO, this) << "Stream timeout stream_id="
+ << downstream->get_stream_id();
+ }
+
+ shutdown_stream(downstream, NGHTTP3_H3_INTERNAL_ERROR);
+
+ handler_->signal_write();
+
+ return 0;
+}
int Http3Upstream::on_downstream_abort_request(Downstream *downstream,
unsigned int status_code) {
@@ -1528,8 +1540,13 @@ void Http3Upstream::on_handler_delete() {
quic_conn_handler->remove_connection_id(cid);
}
- if (retry_close_ || last_error_.type == NGTCP2_CCERR_TYPE_IDLE_CLOSE) {
+ switch (last_error_.type) {
+ case NGTCP2_CCERR_TYPE_IDLE_CLOSE:
+ case NGTCP2_CCERR_TYPE_DROP_CONN:
+ case NGTCP2_CCERR_TYPE_RETRY:
return;
+ default:
+ break;
}
// If this is not idle close, send CONNECTION_CLOSE.
@@ -1823,7 +1840,8 @@ int Http3Upstream::on_read(const UpstreamAddr *faddr,
return -1;
}
- retry_close_ = true;
+ // Overwrite error if any is set
+ ngtcp2_ccerr_set_liberr(&last_error_, rv, nullptr, 0);
quic_conn_handler->send_retry(handler_->get_upstream_addr(), vc.version,
vc.dcid, vc.dcidlen, vc.scid, vc.scidlen,
@@ -1838,6 +1856,9 @@ int Http3Upstream::on_read(const UpstreamAddr *faddr,
}
break;
case NGTCP2_ERR_DROP_CONN:
+ // Overwrite error if any is set
+ ngtcp2_ccerr_set_liberr(&last_error_, rv, nullptr, 0);
+
return -1;
default:
if (!last_error_.error_code) {
@@ -2149,6 +2170,11 @@ int Http3Upstream::http_recv_request_header(Downstream *downstream,
// just ignore if this is a trailer part.
if (trailer) {
+ if (shutdown_stream_read(downstream->get_stream_id(),
+ NGHTTP3_H3_NO_ERROR) != 0) {
+ return -1;
+ }
+
return 0;
}
@@ -2182,7 +2208,6 @@ namespace {
int http_end_request_headers(nghttp3_conn *conn, int64_t stream_id, int fin,
void *user_data, void *stream_user_data) {
auto upstream = static_cast<Http3Upstream *>(user_data);
- auto handler = upstream->get_client_handler();
auto downstream = static_cast<Downstream *>(stream_user_data);
if (!downstream || downstream->get_stop_reading()) {
@@ -2194,7 +2219,7 @@ int http_end_request_headers(nghttp3_conn *conn, int64_t stream_id, int fin,
}
downstream->reset_upstream_rtimer();
- handler->stop_read_timer();
+ downstream->stop_header_timer();
return 0;
}