chenBright commented on code in PR #2934:
URL: https://github.com/apache/brpc/pull/2934#discussion_r2032599274


##########
src/bthread/task_group.cpp:
##########
@@ -372,11 +372,12 @@ void TaskGroup::task_runner(intptr_t skip_remained) {
         // 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.
-        KeyTable* kt = tls_bls.keytable;
+        LocalStorage* tls_bls_ptr = 
BAIDU_GET_PTR_VOLATILE_THREAD_LOCAL(tls_bls);
+        KeyTable* kt = tls_bls_ptr->keytable;
         if (kt != NULL) {
             return_keytable(m->attr.keytable_pool, kt);
             // After deletion: tls may be set during deletion.
-            tls_bls.keytable = NULL;
+            tls_bls_ptr->keytable = NULL;

Review Comment:
   
https://github.com/apache/brpc/blob/724e2fdc4f96fb727d07ab7ae7e48f144965802d/src/bthread/key.cpp#L377-L380
   
   
https://github.com/apache/brpc/blob/724e2fdc4f96fb727d07ab7ae7e48f144965802d/src/bthread/key.cpp#L163-L165
   
   
https://github.com/apache/brpc/blob/724e2fdc4f96fb727d07ab7ae7e48f144965802d/src/bthread/key.cpp#L113-L115
   
   调用户设置的自定义析构函数的时候,bthread可能会挂起。
   
   > 另外return_keytable处理的这个kt,是属于前面取到的tls的,如果后面设置null设置了另一个不同tls,似乎显得有点奇怪?
   
   切到另一个worker上,这个worker上的tls_bls也是当前bthread的吧?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to