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 "panic: send on closed channel" #1438

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

huynhquangtoan
Copy link

No description provided.

@AlexxIT AlexxIT self-assigned this Nov 7, 2024
@@ -99,6 +99,11 @@ func NewSender(media *Media, codec *Codec) *Sender {
s.Input = func(packet *Packet) {
// writing to nil chan - OK, writing to closed chan - panic
s.mu.Lock()
if s.isClosed {
Copy link

Choose a reason for hiding this comment

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

I would recommend to refactor function to use defer s.mu.Unlock(), so it would be closed anyway and the remove all other s.mu.Unlock() instances

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.

3 participants