chenBright commented on code in PR #3543:
URL: https://github.com/apache/brpc/pull/3543#discussion_r4068160825
##########
test/brpc_rtmp_unittest.cpp:
##########
@@ -269,12 +269,19 @@ class PlayingDummyStream : public brpc::RtmpServerStream {
<< " ms before responding play request";
bthread_usleep(_sleep_ms * 1000L);
}
+ // Keep the stream alive until the sender exits, even if a failed send
+ // synchronously runs OnStop() and releases the framework's references.
+ // The guard structurally enforces the handoff: it drops the reference
+ // on any early return and is detached to the sender once it starts.
+ butil::intrusive_ptr<PlayingDummyStream> sender_ref(this);
int rc = bthread_start_background(&_play_thread, nullptr,
RunSendData, this);
if (rc) {
status->set_error(rc, "Fail to create thread");
return;
}
+ // The sender bthread now owns the reference held by the guard.
+ sender_ref.detach();
Review Comment:
Fixed in aae4a25f8462514bbfba2bade5821c8403e7c272 .
--
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]