Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

There is a race in inotify.go:watcher.Close() #367

Copy link
Copy link

Description

@zeripath
Issue body actions

Hi!

Thanks a lot for this library.

Looking at the code I'm suspicious that there is a race in Close():

fsnotify/inotify.go

Lines 72 to 80 in 7f4cf4d

// Close removes all watches and closes the events channel.
func (w *Watcher) Close() error {
if w.isClosed() {
return nil
}
// Send 'close' signal to goroutine, and set the Watcher to closed.
close(w.done)

Is it possible that two concurrent goroutines running Close() could both pass the check function w.isClosed() and then both call close(w.done)? That would result in two closes of the channel and a panic.

One solution would be to lock the w.mu at least around the w.IsClosed and close(w.done) calls.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.