Skip to content

Commit

Permalink
Merge pull request #2106 from nghttp2/nghttpx-simplify-cc-handling
Browse files Browse the repository at this point in the history
nghttpx: Simplify quic connection close handling
  • Loading branch information
tatsuhiro-t committed Mar 18, 2024
2 parents 7d516c2 + ffea7c8 commit 4bda611
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ following libraries are required:
LibreSSL (does not support 0RTT); or aws-lc; or
`BoringSSL <https://boringssl.googlesource.com/boringssl/>`_ (commit
fae0964b3d44e94ca2a2d21f86e61dabe683d130)
* `ngtcp2 <https://github.com/ngtcp2/ngtcp2>`_ >= 1.0.0
* `ngtcp2 <https://github.com/ngtcp2/ngtcp2>`_ >= 1.4.0
* `nghttp3 <https://github.com/ngtcp2/nghttp3>`_ >= 1.1.0

Use ``--enable-http3`` configure option to enable HTTP/3 feature for
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ fi
# ngtcp2 (for src)
have_libngtcp2=no
if test "x${request_libngtcp2}" != "xno"; then
PKG_CHECK_MODULES([LIBNGTCP2], [libngtcp2 >= 1.0.0], [have_libngtcp2=yes],
PKG_CHECK_MODULES([LIBNGTCP2], [libngtcp2 >= 1.4.0], [have_libngtcp2=yes],
[have_libngtcp2=no])
if test "x${have_libngtcp2}" = "xno"; then
AC_MSG_NOTICE($LIBNGTCP2_PKG_ERRORS)
Expand Down
14 changes: 11 additions & 3 deletions src/shrpx_http3_upstream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
} {
Expand Down Expand Up @@ -1540,8 +1539,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.
Expand Down Expand Up @@ -1835,7 +1839,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,
Expand All @@ -1850,6 +1855,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) {
Expand Down
1 change: 0 additions & 1 deletion src/shrpx_http3_upstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ class Http3Upstream : public Upstream {
ngtcp2_ccerr last_error_;
nghttp3_conn *httpconn_;
DownstreamQueue downstream_queue_;
bool retry_close_;
std::vector<uint8_t> conn_close_;

struct {
Expand Down

0 comments on commit 4bda611

Please sign in to comment.