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
0a4330ee
Commit
0a4330ee
authored
Jan 02, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpd: Fix handling pending data and rename rb_ as wb_
parent
d157744f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
22 deletions
+27
-22
src/HttpServer.cc
src/HttpServer.cc
+25
-20
src/HttpServer.h
src/HttpServer.h
+2
-2
No files found.
src/HttpServer.cc
View file @
0a4330ee
...
...
@@ -375,11 +375,16 @@ struct ev_loop *Http2Handler::get_loop() const {
int
Http2Handler
::
setup_bev
()
{
return
0
;
}
int
Http2Handler
::
fill_
r
b
()
{
int
Http2Handler
::
fill_
w
b
()
{
if
(
data_pending_
)
{
assert
(
rb_
.
wleft
()
>=
data_pendinglen_
);
auto
n
=
std
::
min
(
wb_
.
wleft
(),
data_pendinglen_
);
wb_
.
write
(
data_pending_
,
n
);
if
(
n
<
data_pendinglen_
)
{
data_pending_
+=
n
;
data_pendinglen_
-=
n
;
return
0
;
}
rb_
.
write
(
data_pending_
,
data_pendinglen_
);
data_pending_
=
nullptr
;
data_pendinglen_
=
0
;
}
...
...
@@ -396,7 +401,7 @@ int Http2Handler::fill_rb() {
if
(
datalen
==
0
)
{
break
;
}
auto
n
=
r
b_
.
write
(
data
,
datalen
);
auto
n
=
w
b_
.
write
(
data
,
datalen
);
if
(
n
<
static_cast
<
decltype
(
n
)
>
(
datalen
))
{
data_pending_
=
data
+
n
;
data_pendinglen_
=
datalen
-
n
;
...
...
@@ -437,9 +442,9 @@ int Http2Handler::read_clear() {
int
Http2Handler
::
write_clear
()
{
auto
loop
=
sessions_
->
get_loop
();
for
(;;)
{
if
(
r
b_
.
rleft
()
>
0
)
{
if
(
w
b_
.
rleft
()
>
0
)
{
struct
iovec
iov
[
2
];
auto
iovcnt
=
r
b_
.
riovec
(
iov
);
auto
iovcnt
=
w
b_
.
riovec
(
iov
);
ssize_t
nwrite
;
while
((
nwrite
=
writev
(
fd_
,
iov
,
iovcnt
))
==
-
1
&&
errno
==
EINTR
)
...
...
@@ -451,26 +456,26 @@ int Http2Handler::write_clear() {
}
return
-
1
;
}
r
b_
.
drain
(
nwrite
);
w
b_
.
drain
(
nwrite
);
continue
;
}
r
b_
.
reset
();
if
(
fill_
r
b
()
!=
0
)
{
w
b_
.
reset
();
if
(
fill_
w
b
()
!=
0
)
{
return
-
1
;
}
if
(
r
b_
.
rleft
()
==
0
)
{
if
(
w
b_
.
rleft
()
==
0
)
{
break
;
}
}
if
(
r
b_
.
rleft
()
==
0
)
{
if
(
w
b_
.
rleft
()
==
0
)
{
ev_io_stop
(
loop
,
&
wev_
);
}
else
{
ev_io_start
(
loop
,
&
wev_
);
}
if
(
nghttp2_session_want_read
(
session_
)
==
0
&&
nghttp2_session_want_write
(
session_
)
==
0
&&
r
b_
.
rleft
()
==
0
)
{
nghttp2_session_want_write
(
session_
)
==
0
&&
w
b_
.
rleft
()
==
0
)
{
return
-
1
;
}
...
...
@@ -556,10 +561,10 @@ fin:
int
Http2Handler
::
write_tls
()
{
auto
loop
=
sessions_
->
get_loop
();
for
(;;)
{
if
(
r
b_
.
rleft
()
>
0
)
{
if
(
w
b_
.
rleft
()
>
0
)
{
const
void
*
p
;
size_t
len
;
std
::
tie
(
p
,
len
)
=
r
b_
.
get
();
std
::
tie
(
p
,
len
)
=
w
b_
.
get
();
auto
rv
=
SSL_write
(
ssl_
,
p
,
len
);
...
...
@@ -581,26 +586,26 @@ int Http2Handler::write_tls() {
}
}
r
b_
.
drain
(
rv
);
w
b_
.
drain
(
rv
);
continue
;
}
r
b_
.
reset
();
if
(
fill_
r
b
()
!=
0
)
{
w
b_
.
reset
();
if
(
fill_
w
b
()
!=
0
)
{
return
-
1
;
}
if
(
r
b_
.
rleft
()
==
0
)
{
if
(
w
b_
.
rleft
()
==
0
)
{
break
;
}
}
if
(
r
b_
.
rleft
()
==
0
)
{
if
(
w
b_
.
rleft
()
==
0
)
{
ev_io_stop
(
loop
,
&
wev_
);
}
else
{
ev_io_start
(
loop
,
&
wev_
);
}
if
(
nghttp2_session_want_read
(
session_
)
==
0
&&
nghttp2_session_want_write
(
session_
)
==
0
&&
r
b_
.
rleft
()
==
0
)
{
nghttp2_session_want_write
(
session_
)
==
0
&&
w
b_
.
rleft
()
==
0
)
{
return
-
1
;
}
...
...
src/HttpServer.h
View file @
0a4330ee
...
...
@@ -126,7 +126,7 @@ public:
void
remove_settings_timer
();
void
terminate_session
(
uint32_t
error_code
);
int
fill_
r
b
();
int
fill_
w
b
();
int
read_clear
();
int
write_clear
();
...
...
@@ -141,7 +141,7 @@ private:
ev_io
rev_
;
ev_timer
settings_timerev_
;
std
::
map
<
int32_t
,
std
::
unique_ptr
<
Stream
>>
id2stream_
;
RingBuf
<
16384
>
r
b_
;
RingBuf
<
16384
>
w
b_
;
std
::
function
<
int
(
Http2Handler
&
)
>
read_
,
write_
;
int64_t
session_id_
;
nghttp2_session
*
session_
;
...
...
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