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

Panics when sending to closed channel #6

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

akemrir
Copy link
Contributor

@akemrir akemrir commented Aug 25, 2024

Hi,

I am programming one app using this library.
Currently I've moved to newest go release, and I've done upgrade of deps.

I've encountered an issue with channels on very heavy load.

panic: send on closed channel

goroutine 34 [running]:
github.com/illarion/gonotify/v2.NewInotify.func1()
        github.com/illarion/gonotify/[email protected]/inotify.go:105 +0x52d
created by github.com/illarion/gonotify/v2.NewInotify in goroutine 1
        github.com/illarion/gonotify/[email protected]/inotify.go:70 +0x19a

It's easy to reproduce with two loops executed in separate shells:

while true
          touch views/x{29,30,40,50,60}.go
          rm views/x{29,30,40,50,60}.go
end
while true
          touch views/x{129,130,140,150,160}.go
          rm views/x{129,130,140,150,160}.go
end

I noticed that you are closing channel either way, hence small update.
After the fix it stopped to panic. Please review the changes.

@akemrir akemrir changed the title dont-send-to-closed-channel - bugfix Panics when sending to closed channel Aug 25, 2024
@akemrir
Copy link
Contributor Author

akemrir commented Sep 10, 2024

@illarion What do you recon?

@illarion
Copy link
Owner

Yes, you're right, this code is could cause a panic, thank you!

@illarion illarion merged commit dbeaa2a into illarion:master Sep 10, 2024
1 check passed
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.

2 participants