yanglimingcn commented on code in PR #3140:
URL: https://github.com/apache/brpc/pull/3140#discussion_r2521053139
##########
src/brpc/controller.cpp:
##########
@@ -1714,4 +1727,31 @@ void Controller::DoPrintLogPrefix(std::ostream& os)
const {
}
}
+
+#if BRPC_SPAN_ENABLE_SHARED_PTR_API
+ControllerPrivateAccessor& ControllerPrivateAccessor::set_span(
+ std::shared_ptr<Span> span) {
+ _cntl->_span = span;
+ return *this;
+}
+#else
+ControllerPrivateAccessor& ControllerPrivateAccessor::set_span(Span* span) {
+ if (span) {
+ _cntl->_span = span->shared_from_this();
+ } else {
+ _cntl->_span.reset();
+ }
+ return *this;
+}
+#endif
+
+SpanPtr ControllerPrivateAccessor::span() const {
+ std::shared_ptr<Span> span_internal = _cntl->_span.lock();
+#if BRPC_SPAN_ENABLE_SHARED_PTR_API
+ return span_internal;
+#else
+ return span_internal.get();
Review Comment:
return Span* not hold a reference, This will cause problems, won't it?
--
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]