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

SrsKbps::get_recv_kbps may encounter a division by zero exception? #1987

Closed
JalySN opened this issue Oct 12, 2020 · 2 comments
Closed

SrsKbps::get_recv_kbps may encounter a division by zero exception? #1987

JalySN opened this issue Oct 12, 2020 · 2 comments
Assignees
Labels
API HTTP-API, HTTP-Callback, etc. Bug It might be a bug. TransByAI Translated by AI/GPT.
Milestone

Comments

@JalySN
Copy link

JalySN commented Oct 12, 2020

int SrsKbps::get_recv_kbps()
{
srs_utime_t duration = clk->now() - os.starttime;
if (duration <= 0) {
return 0;
}
int64_t bytes = get_recv_bytes();
return (int)(bytes * 8 / srsu2ms(duration));
}

duration< 1000 will result in division by zero

TRANS_BY_GPT3

@JalySN
Copy link
Author

JalySN commented Oct 12, 2020

SrsKbps::get_send_kbps should also have a similar issue.

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented Oct 14, 2020

👍 It has been fixed, and I have picked it to the 3.0 branch: 4ccb838#diff-e156a1170da82b924422f8449d015822167081b84e1f9f3bf358edd3aa36537b

TRANS_BY_GPT3

@winlinvip winlinvip self-assigned this Aug 29, 2021
@winlinvip winlinvip added API HTTP-API, HTTP-Callback, etc. Bug It might be a bug. labels Aug 29, 2021
@winlinvip winlinvip added this to the 3.0 milestone Sep 4, 2021
@winlinvip winlinvip changed the title SrsKbps::get_recv_kbps可能出现除0异常? SrsKbps::get_recv_kbps may encounter a division by zero exception? Jul 28, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API HTTP-API, HTTP-Callback, etc. Bug It might be a bug. TransByAI Translated by AI/GPT.
Projects
None yet
Development

No branches or pull requests

2 participants