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
d32e20bc
Commit
d32e20bc
authored
Dec 16, 2020
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Make sure that Pool gets cleared when all buffers are returned
parent
8b8ba6b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
src/memchunk.h
src/memchunk.h
+5
-1
src/shrpx_worker.cc
src/shrpx_worker.cc
+4
-1
No files found.
src/memchunk.h
View file @
d32e20bc
...
...
@@ -72,7 +72,7 @@ template <size_t N> struct Memchunk {
};
template
<
typename
T
>
struct
Pool
{
Pool
()
:
pool
(
nullptr
),
freelist
(
nullptr
),
poolsize
(
0
)
{}
Pool
()
:
pool
(
nullptr
),
freelist
(
nullptr
),
poolsize
(
0
)
,
freelistsize
(
0
)
{}
~
Pool
()
{
clear
();
}
T
*
get
()
{
if
(
freelist
)
{
...
...
@@ -80,6 +80,7 @@ template <typename T> struct Pool {
freelist
=
freelist
->
next
;
m
->
next
=
nullptr
;
m
->
reset
();
freelistsize
-=
T
::
size
;
return
m
;
}
...
...
@@ -90,9 +91,11 @@ template <typename T> struct Pool {
void
recycle
(
T
*
m
)
{
m
->
next
=
freelist
;
freelist
=
m
;
freelistsize
+=
T
::
size
;
}
void
clear
()
{
freelist
=
nullptr
;
freelistsize
=
0
;
for
(
auto
p
=
pool
;
p
;)
{
auto
knext
=
p
->
knext
;
delete
p
;
...
...
@@ -105,6 +108,7 @@ template <typename T> struct Pool {
T
*
pool
;
T
*
freelist
;
size_t
poolsize
;
size_t
freelistsize
;
};
template
<
typename
Memchunk
>
struct
Memchunks
{
...
...
src/shrpx_worker.cc
View file @
d32e20bc
...
...
@@ -57,7 +57,10 @@ void mcpool_clear_cb(struct ev_loop *loop, ev_timer *w, int revents) {
if
(
worker
->
get_worker_stat
()
->
num_connections
!=
0
)
{
return
;
}
worker
->
get_mcpool
()
->
clear
();
auto
mcpool
=
worker
->
get_mcpool
();
if
(
mcpool
->
freelistsize
==
mcpool
->
poolsize
)
{
worker
->
get_mcpool
()
->
clear
();
}
}
}
// namespace
...
...
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