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
b011012d
Commit
b011012d
authored
May 14, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Use NGHTTP2_DATA_FLAG_NO_COPY for backend HTTP/2 session
parent
8026bdd4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
23 deletions
+59
-23
src/shrpx_http2_downstream_connection.cc
src/shrpx_http2_downstream_connection.cc
+4
-23
src/shrpx_http2_session.cc
src/shrpx_http2_session.cc
+53
-0
src/shrpx_http2_session.h
src/shrpx_http2_session.h
+2
-0
No files found.
src/shrpx_http2_downstream_connection.cc
View file @
b011012d
...
...
@@ -179,24 +179,11 @@ ssize_t http2_data_read_callback(nghttp2_session *session, int32_t stream_id,
}
const
auto
&
req
=
downstream
->
request
();
auto
input
=
downstream
->
get_request_buf
();
auto
nread
=
input
->
remove
(
buf
,
length
);
auto
input_empty
=
input
->
rleft
()
==
0
;
if
(
nread
>
0
)
{
// This is important because it will handle flow control
// stuff.
if
(
downstream
->
get_upstream
()
->
resume_read
(
SHRPX_NO_BUFFER
,
downstream
,
nread
)
!=
0
)
{
// In this case, downstream may be deleted.
return
NGHTTP2_ERR_CALLBACK_FAILURE
;
}
// Check dconn is still alive because Upstream::resume_read()
// may delete downstream which will delete dconn.
if
(
sd
->
dconn
==
nullptr
)
{
return
NGHTTP2_ERR_DEFERRED
;
}
}
auto
nread
=
std
::
min
(
input
->
rleft
(),
length
);
auto
input_empty
=
input
->
rleft
()
==
nread
;
*
data_flags
|=
NGHTTP2_DATA_FLAG_NO_COPY
;
if
(
input_empty
&&
downstream
->
get_request_state
()
==
Downstream
::
MSG_COMPLETE
&&
...
...
@@ -229,12 +216,6 @@ ssize_t http2_data_read_callback(nghttp2_session *session, int32_t stream_id,
}
}
if
(
!
input_empty
)
{
downstream
->
reset_downstream_wtimer
();
}
else
{
downstream
->
disable_downstream_wtimer
();
}
if
(
nread
==
0
&&
(
*
data_flags
&
NGHTTP2_DATA_FLAG_EOF
)
==
0
)
{
downstream
->
disable_downstream_wtimer
();
...
...
src/shrpx_http2_session.cc
View file @
b011012d
...
...
@@ -1362,6 +1362,54 @@ int on_frame_not_send_callback(nghttp2_session *session,
}
}
// namespace
namespace
{
constexpr
auto
PADDING
=
std
::
array
<
uint8_t
,
256
>
{};
}
// namespace
namespace
{
int
send_data_callback
(
nghttp2_session
*
session
,
nghttp2_frame
*
frame
,
const
uint8_t
*
framehd
,
size_t
length
,
nghttp2_data_source
*
source
,
void
*
user_data
)
{
auto
http2session
=
static_cast
<
Http2Session
*>
(
user_data
);
auto
sd
=
static_cast
<
StreamData
*>
(
nghttp2_session_get_stream_user_data
(
session
,
frame
->
hd
.
stream_id
));
auto
dconn
=
sd
->
dconn
;
auto
downstream
=
dconn
->
get_downstream
();
auto
input
=
downstream
->
get_request_buf
();
auto
wb
=
http2session
->
get_request_buf
();
size_t
padlen
=
0
;
wb
->
append
(
framehd
,
9
);
if
(
frame
->
data
.
padlen
>
0
)
{
padlen
=
frame
->
data
.
padlen
-
1
;
wb
->
append
(
static_cast
<
uint8_t
>
(
padlen
));
}
input
->
remove
(
*
wb
,
length
);
wb
->
append
(
PADDING
.
data
(),
padlen
);
downstream
->
reset_downstream_wtimer
();
if
(
length
>
0
)
{
// This is important because it will handle flow control
// stuff.
if
(
downstream
->
get_upstream
()
->
resume_read
(
SHRPX_NO_BUFFER
,
downstream
,
length
)
!=
0
)
{
// In this case, downstream may be deleted.
return
NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE
;
}
// Here sd->dconn could be nullptr, because
// Upstream::resume_read() may delete downstream which will delete
// dconn. Is this still really true?
}
return
0
;
}
}
// namespace
nghttp2_session_callbacks
*
create_http2_downstream_callbacks
()
{
int
rv
;
nghttp2_session_callbacks
*
callbacks
;
...
...
@@ -1393,6 +1441,9 @@ nghttp2_session_callbacks *create_http2_downstream_callbacks() {
nghttp2_session_callbacks_set_on_begin_headers_callback
(
callbacks
,
on_begin_headers_callback
);
nghttp2_session_callbacks_set_send_data_callback
(
callbacks
,
send_data_callback
);
if
(
get_config
()
->
padding
)
{
nghttp2_session_callbacks_set_select_padding_callback
(
callbacks
,
http
::
select_padding_callback
);
...
...
@@ -2115,4 +2166,6 @@ void Http2Session::exclude_from_scheduling() {
freelist_zone_
=
FREELIST_ZONE_GONE
;
}
DefaultMemchunks
*
Http2Session
::
get_request_buf
()
{
return
&
wb_
;
}
}
// namespace shrpx
src/shrpx_http2_session.h
View file @
b011012d
...
...
@@ -195,6 +195,8 @@ public:
// server initiated concurrency limit.
bool
max_concurrency_reached
(
size_t
extra
=
0
)
const
;
DefaultMemchunks
*
get_request_buf
();
enum
{
// Disconnected
DISCONNECTED
,
...
...
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