This is an automated email from the ASF dual-hosted git repository.
jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git
The following commit(s) were added to refs/heads/master by this push:
new e1f7c9bc fix the problem that the first bthread keytable on worker
pthread will be deleted twice
new a0fc1a2c Merge pull request #1884 from
chenBright/fix_double_delete_keytable
e1f7c9bc is described below
commit e1f7c9bc5b959de132fb96610875b866020edda9
Author: chenguangming <[email protected]>
AuthorDate: Fri Aug 12 19:24:06 2022 +0800
fix the problem that the first bthread keytable on worker pthread will be
deleted twice
---
src/bthread/key.cpp | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/bthread/key.cpp b/src/bthread/key.cpp
index a4a08407..ca5e079d 100644
--- a/src/bthread/key.cpp
+++ b/src/bthread/key.cpp
@@ -446,10 +446,14 @@ int bthread_setspecific(bthread_key_t key, void* data) {
bthread::TaskGroup* const g = bthread::tls_task_group;
if (g) {
g->current_task()->local_storage.keytable = kt;
- }
- if (!bthread::tls_ever_created_keytable) {
- bthread::tls_ever_created_keytable = true;
- CHECK_EQ(0, butil::thread_atexit(bthread::cleanup_pthread, kt));
+ } else {
+ // Only cleanup keytable created by pthread.
+ // keytable created by bthread will be deleted
+ // in `return_keytable' or `bthread_keytable_pool_destroy'.
+ if (!bthread::tls_ever_created_keytable) {
+ bthread::tls_ever_created_keytable = true;
+ CHECK_EQ(0, butil::thread_atexit(bthread::cleanup_pthread,
kt));
+ }
}
}
return kt->set_data(key, data);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]