Copilot commented on code in PR #3709:
URL: https://github.com/apache/brpc/pull/3709#discussion_r4466752480


##########
src/bvar/detail/combiner.h:
##########
@@ -340,6 +340,15 @@ friend class GlobalValue<self_type>;
         call_op_returning_void(_op, _global_result, prev);
     }
 
+    AgentId agent_id() const { return _id; }
+
+    // The caller must keep the combiner owning id alive. An allocated TLS
+    // slot may still be unbound, or belong to an expired combiner after reuse.
+    inline static Agent* get_bound_tls_agent(AgentId id) {
+        Agent* agent = AgentGroup::get_tls_agent(id);
+        return agent && !agent->combiner.expired() ? agent : nullptr;
+    }

Review Comment:
   This changes the hot path and adds a distinct expired-binding fallback, but 
there is no regression test for the case that exercises that fallback: destroy 
one native recorder/reducer after it has bound the current thread's agent, then 
construct another of the same type so the AgentId/TLS slot is reused and verify 
the new metric receives only its own writes. The existing write tests cover 
initial binding and successful aggregation, not stale-slot reuse; please add a 
focused test for this lifetime boundary.



-- 
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]

Reply via email to