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

fix: rtmp: read timeout #67 #68

Merged
merged 2 commits into from
Oct 27, 2023
Merged

Conversation

ningnao
Copy link
Contributor

@ningnao ningnao commented Oct 26, 2023

修复 #67 中因阻塞导致超时断开链接逻辑未能正确执行以及异常信息被覆盖的问题

}
},
Err(_) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在BytesIOError里面可以定义一个tokio::time::error::Elapsed 枚举类型,然后可以把这个error传递出去。

loop {
match self.read().await {
match tokio::time::timeout(duration, self.read()).await {
Copy link
Owner

@harlanc harlanc Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段写法可以再简化一下吧,像下面这样,loop是不是也没用了?

match tokio::time::timeout(duration, self.read()).await {
Ok(data) => data,
Err(err) => Err(BytesIOError {
value: BytesIOErrorValue::TimeoutError(err),
}),
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢指导,我调整了一下代码提交了

@harlanc harlanc merged commit 135cc82 into harlanc:master Oct 27, 2023
@harlanc
Copy link
Owner

harlanc commented Oct 27, 2023

Thanks

@harlanc harlanc linked an issue Oct 27, 2023 that may be closed by this pull request
@ningnao ningnao deleted the fix-rtmp-timeout branch December 3, 2023 03:12
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

Successfully merging this pull request may close these issues.

RTMP 推送设备断电后,超时逻辑未能正确执行
2 participants