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
72c51354
Commit
72c51354
authored
Apr 02, 2018
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix the problem that tls data cannot be read in destructor which is specified by pthread_key_create
parent
0fe6c3d0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
4 deletions
+3
-4
key.cpp
src/bthread/key.cpp
+3
-4
No files found.
src/bthread/key.cpp
View file @
72c51354
...
@@ -233,9 +233,8 @@ void return_keytable(bthread_keytable_pool_t* pool, KeyTable* kt) {
...
@@ -233,9 +233,8 @@ void return_keytable(bthread_keytable_pool_t* pool, KeyTable* kt) {
pool
->
free_keytables
=
kt
;
pool
->
free_keytables
=
kt
;
}
}
static
void
cleanup_pthread
()
{
static
void
cleanup_pthread
(
void
*
arg
)
{
KeyTable
*
kt
=
tls_bls
.
keytable
;
KeyTable
*
kt
=
static_cast
<
KeyTable
*>
(
arg
);
//TODO(zhujiashun): thread local storage not works in macos using clang
if
(
kt
)
{
if
(
kt
)
{
delete
kt
;
delete
kt
;
// After deletion: tls may be set during deletion.
// After deletion: tls may be set during deletion.
...
@@ -447,7 +446,7 @@ int bthread_setspecific(bthread_key_t key, void* data) {
...
@@ -447,7 +446,7 @@ int bthread_setspecific(bthread_key_t key, void* data) {
}
}
if
(
!
bthread
::
tls_ever_created_keytable
)
{
if
(
!
bthread
::
tls_ever_created_keytable
)
{
bthread
::
tls_ever_created_keytable
=
true
;
bthread
::
tls_ever_created_keytable
=
true
;
CHECK_EQ
(
0
,
butil
::
thread_atexit
(
bthread
::
cleanup_pthread
));
CHECK_EQ
(
0
,
butil
::
thread_atexit
(
bthread
::
cleanup_pthread
,
kt
));
}
}
}
}
return
kt
->
set_data
(
key
,
data
);
return
kt
->
set_data
(
key
,
data
);
...
...
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