Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
0971bf63
Commit
0971bf63
authored
Sep 29, 2017
by
gejun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
r35332: Fix logging memory leak after keytable is returned
parent
2ae045ba
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
task_group.cpp
src/bthread/task_group.cpp
+14
-8
No files found.
src/bthread/task_group.cpp
View file @
0971bf63
...
...
@@ -331,6 +331,14 @@ void TaskGroup::task_runner(intptr_t skip_remained) {
// TODO: Save thread_return
(
void
)
thread_return
;
// Logging must be done before returning the keytable, since the logging lib
// use bthread local storage internally, or will cause memory leak.
// FIXME: the time from quiting fn to here is not counted into cputime
if
(
m
->
attr
.
flags
&
BTHREAD_LOG_START_AND_FINISH
)
{
LOG
(
INFO
)
<<
"Finished bthread "
<<
m
->
tid
<<
", cputime="
<<
m
->
stat
.
cputime_ns
/
1000000.0
<<
"ms"
;
}
// Clean tls variables, must be done before changing version_butex
// otherwise another thread just joined this thread may not see side
// effects of destructing tls variables.
...
...
@@ -354,12 +362,6 @@ void TaskGroup::task_runner(intptr_t skip_remained) {
}
butex_wake_except
(
m
->
version_butex
,
0
);
// FIXME: the time from quiting fn to here is not counted into cputime
if
(
m
->
attr
.
flags
&
BTHREAD_LOG_START_AND_FINISH
)
{
LOG
(
INFO
)
<<
"Finished bthread "
<<
m
->
tid
<<
", cputime="
<<
m
->
stat
.
cputime_ns
/
1000000.0
<<
"ms"
;
}
g
->
_control
->
_nbthreads
<<
-
1
;
g
->
set_remained
(
TaskGroup
::
_release_last_context
,
m
);
ending_sched
(
&
g
);
...
...
@@ -625,13 +627,17 @@ void TaskGroup::sched_to(TaskGroup** pg, TaskMeta* next_meta) {
++
g
->
_nswitch
;
// Switch to the task
if
(
__builtin_expect
(
next_meta
!=
cur_meta
,
1
))
{
g
->
_cur_meta
=
next_meta
;
tls_bls
=
next_meta
->
local_storage
;
// Logging must be done after switching the local storage, since the logging lib
// use bthread local storage internally, or will cause memory leak.
if
((
cur_meta
->
attr
.
flags
&
BTHREAD_LOG_CONTEXT_SWITCH
)
||
(
next_meta
->
attr
.
flags
&
BTHREAD_LOG_CONTEXT_SWITCH
))
{
LOG
(
INFO
)
<<
"Switch bthread: "
<<
cur_meta
->
tid
<<
" -> "
<<
next_meta
->
tid
;
}
g
->
_cur_meta
=
next_meta
;
tls_bls
=
next_meta
->
local_storage
;
if
(
cur_meta
->
stack
!=
NULL
)
{
if
(
next_meta
->
stack
!=
cur_meta
->
stack
)
{
jump_stack
(
cur_meta
->
stack
,
next_meta
->
stack
);
...
...
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