Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RtspServer Bug #92

Open
BreakingY opened this issue Aug 27, 2024 · 2 comments
Open

RtspServer Bug #92

BreakingY opened this issue Aug 27, 2024 · 2 comments

Comments

@BreakingY
Copy link

BreakingY commented Aug 27, 2024

一、TaskScheduler::HandleTriggerEvent()应该加锁,多线程下有内存泄漏风险
二、RtpConnection::SendRtpPacket(MediaChannelId channel_id, RtpPacket pkt):----客户端关闭的时候如果有音视频数据要发送时候会引发死锁 ok √
原因如下:
RtpConnection::SendRtpPacket中如果通过AddTriggerEvent发送数据,步骤如下:
...
1、TaskScheduler::AddTriggerEvent lock-->unlock
2、TaskScheduler::HandleTriggerEvent lock
3、执行RtpConnection::SendRtpPacket中设置的回调函数
4、调用TcpConnection::Send函数发送数据,lock TcpConnection::mutex_
客户端关闭流程如下:
1、epoll触发TcpConnection::HandleClose()函数,lock TcpConnection::mutex_
2、TcpConnection调用回调函数disconnect_cb_和close_cb_ disconnect_cb_由TcpServer注册
3、TcpServer注册的回调函数通过AddTriggerEvent调用TcpServer::RemoveConnection删除客户端缓存,TaskScheduler::AddTriggerEvent lock
问题出现了:
发送数据时候:TaskScheduler lock-->TcpConnection lock
客户端关闭时候:TcpConnection lock-->TaskScheduler lock
出现死锁
解决方式:
1、RtpConnection::SendRtpPacket中不使用AddTriggerEvent
2、TcpServer构造函数中不使用AddTriggerEvent
三、TimerQueue::HandleTimerEvent():如果超时,定时器队列中的数据没有被删除,导致内存泄露
四、RtspConnection::HandleCmdSetup()中rtcp_channels_[channel_id]->SetReadCallback(rtcp_fd, this { this->HandleRtcp(rtcp_fd); });也有问题
此时rtcp_fd是UDP,而HandleRtcp中是对客户端的tcp socket接受数据,实际并没有处理RTCP数据,因此这里不影响正常运行,可忽略。

@DeguiLiu
Copy link

可以分享一下你的修复commit吗?

@BreakingY
Copy link
Author

没有commit,你就按照上面提出来的改就行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants