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
0872ce27
Commit
0872ce27
authored
Jan 18, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Use nghttp2_session_mem_recv instead of nghttp2_session_recv
parent
50dd7ada
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
71 deletions
+45
-71
src/shrpx_http2_session.cc
src/shrpx_http2_session.cc
+22
-35
src/shrpx_http2_upstream.cc
src/shrpx_http2_upstream.cc
+23
-36
No files found.
src/shrpx_http2_session.cc
View file @
0872ce27
...
...
@@ -711,24 +711,6 @@ ssize_t send_callback(nghttp2_session *session,
}
}
// namespace
namespace
{
ssize_t
recv_callback
(
nghttp2_session
*
session
,
uint8_t
*
data
,
size_t
len
,
int
flags
,
void
*
user_data
)
{
auto
http2session
=
reinterpret_cast
<
Http2Session
*>
(
user_data
);
auto
bev
=
http2session
->
get_bev
();
auto
input
=
bufferevent_get_input
(
bev
);
int
nread
=
evbuffer_remove
(
input
,
data
,
len
);
if
(
nread
==
-
1
)
{
return
NGHTTP2_ERR_CALLBACK_FAILURE
;
}
else
if
(
nread
==
0
)
{
return
NGHTTP2_ERR_WOULDBLOCK
;
}
else
{
return
nread
;
}
}
}
// namespace
namespace
{
int
on_stream_close_callback
(
nghttp2_session
*
session
,
int32_t
stream_id
,
nghttp2_error_code
error_code
,
...
...
@@ -1215,7 +1197,6 @@ int Http2Session::on_connect()
nghttp2_session_callbacks
callbacks
;
memset
(
&
callbacks
,
0
,
sizeof
(
callbacks
));
callbacks
.
send_callback
=
send_callback
;
callbacks
.
recv_callback
=
recv_callback
;
callbacks
.
on_stream_close_callback
=
on_stream_close_callback
;
callbacks
.
on_frame_recv_callback
=
on_frame_recv_callback
;
callbacks
.
on_data_chunk_recv_callback
=
on_data_chunk_recv_callback
;
...
...
@@ -1290,27 +1271,33 @@ int Http2Session::on_connect()
int
Http2Session
::
on_read
()
{
int
rv
=
0
;
if
((
rv
=
nghttp2_session_recv
(
session_
))
<
0
)
{
if
(
rv
!=
NGHTTP2_ERR_EOF
)
{
SSLOG
(
ERROR
,
this
)
<<
"nghttp2_session_recv() returned error: "
<<
nghttp2_strerror
(
rv
);
}
}
else
if
((
rv
=
nghttp2_session_send
(
session_
))
<
0
)
{
ssize_t
rv
=
0
;
auto
input
=
bufferevent_get_input
(
bev_
);
auto
inputlen
=
evbuffer_get_length
(
input
);
auto
mem
=
evbuffer_pullup
(
input
,
-
1
);
rv
=
nghttp2_session_mem_recv
(
session_
,
mem
,
inputlen
);
if
(
rv
<
0
)
{
SSLOG
(
ERROR
,
this
)
<<
"nghttp2_session_recv() returned error: "
<<
nghttp2_strerror
(
rv
);
return
-
1
;
}
evbuffer_drain
(
input
,
rv
);
rv
=
nghttp2_session_send
(
session_
);
if
(
rv
<
0
)
{
SSLOG
(
ERROR
,
this
)
<<
"nghttp2_session_send() returned error: "
<<
nghttp2_strerror
(
rv
);
return
-
1
;
}
if
(
rv
==
0
)
{
if
(
nghttp2_session_want_read
(
session_
)
==
0
&&
nghttp2_session_want_write
(
session_
)
==
0
&&
evbuffer_get_length
(
bufferevent_get_output
(
bev_
))
==
0
)
{
if
(
LOG_ENABLED
(
INFO
))
{
SSLOG
(
INFO
,
this
)
<<
"No more read/write for this session"
;
}
rv
=
-
1
;
if
(
nghttp2_session_want_read
(
session_
)
==
0
&&
nghttp2_session_want_write
(
session_
)
==
0
&&
evbuffer_get_length
(
bufferevent_get_output
(
bev_
))
==
0
)
{
if
(
LOG_ENABLED
(
INFO
))
{
SSLOG
(
INFO
,
this
)
<<
"No more read/write for this session"
;
}
return
-
1
;
}
return
rv
;
return
0
;
}
int
Http2Session
::
on_write
()
...
...
src/shrpx_http2_upstream.cc
View file @
0872ce27
...
...
@@ -73,25 +73,6 @@ ssize_t send_callback(nghttp2_session *session,
}
}
// namespace
namespace
{
ssize_t
recv_callback
(
nghttp2_session
*
session
,
uint8_t
*
data
,
size_t
len
,
int
flags
,
void
*
user_data
)
{
auto
upstream
=
reinterpret_cast
<
Http2Upstream
*>
(
user_data
);
auto
handler
=
upstream
->
get_client_handler
();
auto
bev
=
handler
->
get_bev
();
auto
input
=
bufferevent_get_input
(
bev
);
int
nread
=
evbuffer_remove
(
input
,
data
,
len
);
if
(
nread
==
-
1
)
{
return
NGHTTP2_ERR_CALLBACK_FAILURE
;
}
else
if
(
nread
==
0
)
{
return
NGHTTP2_ERR_WOULDBLOCK
;
}
else
{
return
nread
;
}
}
}
// namespace
namespace
{
int
on_stream_close_callback
(
nghttp2_session
*
session
,
int32_t
stream_id
,
nghttp2_error_code
error_code
,
...
...
@@ -533,7 +514,6 @@ Http2Upstream::Http2Upstream(ClientHandler *handler)
nghttp2_session_callbacks
callbacks
;
memset
(
&
callbacks
,
0
,
sizeof
(
callbacks
));
callbacks
.
send_callback
=
send_callback
;
callbacks
.
recv_callback
=
recv_callback
;
callbacks
.
on_stream_close_callback
=
on_stream_close_callback
;
callbacks
.
on_frame_recv_callback
=
on_frame_recv_callback
;
callbacks
.
on_data_chunk_recv_callback
=
on_data_chunk_recv_callback
;
...
...
@@ -593,27 +573,34 @@ Http2Upstream::~Http2Upstream()
int
Http2Upstream
::
on_read
()
{
int
rv
=
0
;
if
((
rv
=
nghttp2_session_recv
(
session_
))
<
0
)
{
if
(
rv
!=
NGHTTP2_ERR_EOF
)
{
ULOG
(
ERROR
,
this
)
<<
"nghttp2_session_recv() returned error: "
<<
nghttp2_strerror
(
rv
);
}
}
else
if
((
rv
=
nghttp2_session_send
(
session_
))
<
0
)
{
ssize_t
rv
=
0
;
auto
bev
=
handler_
->
get_bev
();
auto
input
=
bufferevent_get_input
(
bev
);
auto
inputlen
=
evbuffer_get_length
(
input
);
auto
mem
=
evbuffer_pullup
(
input
,
-
1
);
rv
=
nghttp2_session_mem_recv
(
session_
,
mem
,
inputlen
);
if
(
rv
<
0
)
{
ULOG
(
ERROR
,
this
)
<<
"nghttp2_session_recv() returned error: "
<<
nghttp2_strerror
(
rv
);
return
-
1
;
}
evbuffer_drain
(
input
,
rv
);
rv
=
nghttp2_session_send
(
session_
);
if
(
rv
<
0
)
{
ULOG
(
ERROR
,
this
)
<<
"nghttp2_session_send() returned error: "
<<
nghttp2_strerror
(
rv
);
return
-
1
;
}
if
(
rv
==
0
)
{
if
(
nghttp2_session_want_read
(
session_
)
==
0
&&
nghttp2_session_want_write
(
session_
)
==
0
&&
evbuffer_get_length
(
bufferevent_get_output
(
handler_
->
get_bev
()))
==
0
)
{
if
(
LOG_ENABLED
(
INFO
))
{
ULOG
(
INFO
,
this
)
<<
"No more read/write for this HTTP2 session"
;
}
rv
=
-
1
;
if
(
nghttp2_session_want_read
(
session_
)
==
0
&&
nghttp2_session_want_write
(
session_
)
==
0
&&
evbuffer_get_length
(
bufferevent_get_output
(
bev
))
==
0
)
{
if
(
LOG_ENABLED
(
INFO
))
{
ULOG
(
INFO
,
this
)
<<
"No more read/write for this HTTP2 session"
;
}
rv
=
-
1
;
}
return
rv
;
return
0
;
}
int
Http2Upstream
::
on_write
()
...
...
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