lh2debug-2 commented on code in PR #3421:
URL: https://github.com/apache/brpc/pull/3421#discussion_r3733101007


##########
src/brpc/span.cpp:
##########
@@ -581,13 +586,13 @@ inline int GetSpanDB(butil::intrusive_ptr<SpanDB>* db) {
 }
 
 void Span::Submit(std::shared_ptr<Span> span, int64_t cpuwide_time_us) {
-    // Only submit spans without a local parent (i.e., server spans).
-    // Server spans hold shared_ptr references to their child spans (via 
_client_list),
-    // ensuring child spans remain alive until the server span is submitted 
and dumped.
-    // Client spans are not submitted here because their lifetime is managed 
by their
-    // parent server span.
+    // Submit root spans without a local parent. Server spans and root client
+    // spans are submitted independently; child client spans with a live local
+    // parent are serialized under the parent to avoid duplicate submissions.
     if (span->local_parent().expired()) {
-        span->submit(cpuwide_time_us);
+        if (span->TryMarkSubmitted()) {

Review Comment:
   done



##########
src/brpc/span.h:
##########
@@ -198,6 +199,11 @@ friend class SpanContainer;
 
     void dump_to_db();
     void submit(int64_t cpuwide_us);
+    bool TryMarkSubmitted() const {

Review Comment:
   done



##########
src/brpc/controller.cpp:
##########
@@ -183,7 +183,7 @@ static void CreateIgnoreAllRead() { s_ignore_all_read = new 
IgnoreAllRead; }
 // you don't have to set the fields to initial state after deletion since
 // they'll be set uniformly after this method is called.
 void Controller::ResetNonPods() {
-    if (auto span = _span.lock()) {
+    if (auto span = _span) {

Review Comment:
   done



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