File tree Expand file tree Collapse file tree
runtime/threadmodel/fiber Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,9 +103,13 @@ struct convert<trpc::ServiceProxyConfig> {
103103 if (node[" recv_buffer_size" ]) proxy_config.recv_buffer_size = node[" recv_buffer_size" ].as <uint32_t >();
104104 if (node[" send_queue_capacity" ]) proxy_config.send_queue_capacity = node[" send_queue_capacity" ].as <uint32_t >();
105105 if (node[" send_queue_timeout" ]) proxy_config.send_queue_timeout = node[" send_queue_timeout" ].as <uint32_t >();
106- if (node[" endpoint_hash_bucket_size" ]) proxy_config.endpoint_hash_bucket_size = node[" endpoint_hash_bucket_size" ].as <uint32_t >();
106+ if (node[" endpoint_hash_bucket_size" ]) {
107+ proxy_config.endpoint_hash_bucket_size = node[" endpoint_hash_bucket_size" ].as <uint32_t >();
108+ }
107109 if (node[" threadmodel_type" ]) proxy_config.threadmodel_type = node[" threadmodel_type" ].as <std::string>();
108- if (node[" threadmodel_instance_name" ]) proxy_config.threadmodel_instance_name = node[" threadmodel_instance_name" ].as <std::string>();
110+ if (node[" threadmodel_instance_name" ]) {
111+ proxy_config.threadmodel_instance_name = node[" threadmodel_instance_name" ].as <std::string>();
112+ }
109113 if (node[" selector_name" ]) proxy_config.selector_name = node[" selector_name" ].as <std::string>();
110114 if (node[" namespace" ]) proxy_config.namespace_ = node[" namespace" ].as <std::string>();
111115 if (node[" load_balance_name" ]) proxy_config.load_balance_name = node[" load_balance_name" ].as <std::string>();
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ extern "C" {
4848
4949// FIXME: TSan support does not work yet.
5050#ifdef TRPC_INTERNAL_USE_TSAN
51+ #ifndef TRPC_INTERNAL_EXCLUDE_TSAN_INTERFACE
5152extern " C" {
5253[[gnu::weak]] void * __tsan_get_current_fiber (void );
5354[[gnu::weak]] void * __tsan_create_fiber (unsigned );
@@ -78,6 +79,7 @@ const unsigned __tsan_mutex_recursive_unlock = 1 << 7;
7879[[gnu::weak]] void __tsan_acquire (void *);
7980[[gnu::weak]] void __tsan_release (void *);
8081}
82+ #endif
8183
8284#define TRPC_INTERNAL_TSAN_MUTEX_CREATE (...) __tsan_mutex_create(__VA_ARGS__)
8385#define TRPC_INTERNAL_TSAN_MUTEX_DESTROY (...) __tsan_mutex_destroy(__VA_ARGS__)
Original file line number Diff line number Diff line change @@ -129,16 +129,27 @@ void FiberThreadModel::Start() noexcept {
129129}
130130
131131void FiberThreadModel::Terminate () noexcept {
132+ // Exit the timer worker first due to it uses the tls variable of the FiberWorker thread.
132133 for (auto && e : scheduling_groups_) {
133134 for (auto && ee : e) {
134135 ee->timer_worker ->Stop ();
135- ee->scheduling_group ->Stop ();
136136 }
137137 }
138138
139139 for (auto && e : scheduling_groups_) {
140140 for (auto && ee : e) {
141141 ee->timer_worker ->Join ();
142+ }
143+ }
144+
145+ for (auto && e : scheduling_groups_) {
146+ for (auto && ee : e) {
147+ ee->scheduling_group ->Stop ();
148+ }
149+ }
150+
151+ for (auto && e : scheduling_groups_) {
152+ for (auto && ee : e) {
142153 for (auto && eee : ee->fiber_workers ) {
143154 eee->Join ();
144155 }
You can’t perform that action at this time.
0 commit comments