Copilot commented on code in PR #3543:
URL: https://github.com/apache/brpc/pull/3543#discussion_r4026355886
##########
test/brpc_rtmp_unittest.cpp:
##########
@@ -289,16 +296,26 @@ class PlayingDummyStream : public brpc::RtmpServerStream {
void OnStop() {
LOG(INFO) << "OnStop of PlayingDummyStream=" << this;
if (_state.exchange(STATE_STOPPED) == STATE_PLAYING) {
- bthread_stop(_play_thread);
- bthread_join(_play_thread, nullptr);
+ // A send failure can invoke this callback on the sender bthread
+ // itself. Stopping or joining the current bthread is unsafe and
+ // interferes with its unwinding, and the sender's own reference
+ // already keeps the stream alive until SendData returns, so only
+ // stop and join when running on a different bthread.
+ if (_play_thread != bthread_self()) {
+ bthread_stop(_play_thread);
+ bthread_join(_play_thread, nullptr);
+ }
Review Comment:
On the self-callback path this skips both `bthread_stop` and `bthread_join`.
`SendData` only exits when `bthread_stopped(bthread_self())` becomes true, and
both send return values are ignored, so a synchronous write failure leaves this
sender looping/sleeping forever while retaining its stream reference. Keep the
stop operation for the current bthread and only omit the self-join (or make
`SendData` terminate on the failed send).
This issue also appears on line 362 of the same file.
--
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]