Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
17012654
Commit
17012654
authored
Aug 31, 2021
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Add HTTP/3 graceful shutdown
parent
e998d125
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
0 deletions
+87
-0
src/shrpx_http3_upstream.cc
src/shrpx_http3_upstream.cc
+82
-0
src/shrpx_http3_upstream.h
src/shrpx_http3_upstream.h
+5
-0
No files found.
src/shrpx_http3_upstream.cc
View file @
17012654
...
...
@@ -76,6 +76,28 @@ fail:
}
}
// namespace
namespace
{
void
shutdown_timeout_cb
(
struct
ev_loop
*
loop
,
ev_timer
*
w
,
int
revents
)
{
auto
upstream
=
static_cast
<
Http3Upstream
*>
(
w
->
data
);
auto
handler
=
upstream
->
get_client_handler
();
if
(
upstream
->
submit_goaway
()
!=
0
)
{
delete
handler
;
}
}
}
// namespace
namespace
{
void
prepare_cb
(
struct
ev_loop
*
loop
,
ev_prepare
*
w
,
int
revent
)
{
auto
upstream
=
static_cast
<
Http3Upstream
*>
(
w
->
data
);
auto
handler
=
upstream
->
get_client_handler
();
if
(
upstream
->
check_shutdown
()
!=
0
)
{
delete
handler
;
}
}
}
// namespace
namespace
{
size_t
downstream_queue_size
(
Worker
*
worker
)
{
auto
&
downstreamconf
=
*
worker
->
get_downstream_config
();
...
...
@@ -104,11 +126,20 @@ Http3Upstream::Http3Upstream(ClientHandler *handler)
ev_timer_init
(
&
idle_timer_
,
idle_timeoutcb
,
0.
,
quicconf
.
upstream
.
timeout
.
idle
);
idle_timer_
.
data
=
this
;
ev_timer_init
(
&
shutdown_timer_
,
shutdown_timeout_cb
,
0.
,
0.
);
shutdown_timer_
.
data
=
this
;
ev_prepare_init
(
&
prep_
,
prepare_cb
);
prep_
.
data
=
this
;
ev_prepare_start
(
handler_
->
get_loop
(),
&
prep_
);
}
Http3Upstream
::~
Http3Upstream
()
{
auto
loop
=
handler_
->
get_loop
();
ev_prepare_stop
(
loop
,
&
prep_
);
ev_timer_stop
(
loop
,
&
shutdown_timer_
);
ev_timer_stop
(
loop
,
&
idle_timer_
);
ev_timer_stop
(
loop
,
&
timer_
);
...
...
@@ -2400,4 +2431,55 @@ void Http3Upstream::log_response_headers(
<<
ss
.
str
();
}
int
Http3Upstream
::
check_shutdown
()
{
auto
worker
=
handler_
->
get_worker
();
if
(
!
worker
->
get_graceful_shutdown
())
{
return
0
;
}
ev_prepare_stop
(
handler_
->
get_loop
(),
&
prep_
);
return
start_graceful_shutdown
();
}
int
Http3Upstream
::
start_graceful_shutdown
()
{
int
rv
;
if
(
ev_is_active
(
&
shutdown_timer_
))
{
return
0
;
}
rv
=
nghttp3_conn_submit_shutdown_notice
(
httpconn_
);
if
(
rv
!=
0
)
{
ULOG
(
FATAL
,
this
)
<<
"nghttp3_conn_submit_shutdown_notice: "
<<
nghttp3_strerror
(
rv
);
return
-
1
;
}
handler_
->
signal_write
();
auto
t
=
ngtcp2_conn_get_pto
(
conn_
);
ev_timer_set
(
&
shutdown_timer_
,
static_cast
<
ev_tstamp
>
(
t
)
*
3
/
NGTCP2_SECONDS
,
0.
);
ev_timer_start
(
handler_
->
get_loop
(),
&
shutdown_timer_
);
return
0
;
}
int
Http3Upstream
::
submit_goaway
()
{
int
rv
;
rv
=
nghttp3_conn_shutdown
(
httpconn_
);
if
(
rv
!=
0
)
{
ULOG
(
FATAL
,
this
)
<<
"nghttp3_conn_shutdown: "
<<
nghttp3_strerror
(
rv
);
return
-
1
;
}
handler_
->
signal_write
();
return
0
;
}
}
// namespace shrpx
src/shrpx_http3_upstream.h
View file @
17012654
...
...
@@ -144,11 +144,16 @@ public:
int
http_recv_data
(
Downstream
*
downstream
,
const
uint8_t
*
data
,
size_t
datalen
);
int
handshake_completed
();
int
check_shutdown
();
int
start_graceful_shutdown
();
int
submit_goaway
();
private:
ClientHandler
*
handler_
;
ev_timer
timer_
;
ev_timer
idle_timer_
;
ev_timer
shutdown_timer_
;
ev_prepare
prep_
;
ngtcp2_cid
initial_client_dcid_
;
ngtcp2_conn
*
conn_
;
quic
::
Error
last_error_
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment