ehds commented on issue #2203: URL: https://github.com/apache/brpc/issues/2203#issuecomment-1502936336
可以尝试开启 `usercode_in_pthread`, > 代码中广泛地使用pthread local传递session级别全局数据,在RPC前后均使用了相同的pthread local的数据,且数据有前后依赖性。比如在RPC前往pthread-local保存了一个值,RPC后又读出来希望和之前保存的相等,就会有问题。而像tcmalloc虽然也使用了pthread/LWP local,但每次使用之间没有直接的依赖,是安全的。 对于这些情况,brpc提供了pthread模式,开启**-usercode_in_pthread**后,用户代码均会在pthread中运行,原先阻塞bthread的函数转而阻塞pthread。 参考这个文档 https://github.com/apache/brpc/blob/master/docs/cn/server.md#pthread%E6%A8%A1%E5%BC%8F 如果在 server 处理用户请求的代码中,如果没有发生能导致 bthread 阻塞的函数,例如 bthread::usleep、 bthread::bthread_start_urgent 等这些函数,线程是不会发生切换的。 -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
