Skip to content

Conversation

arp242
Copy link
Member

@arp242 arp242 commented Mar 31, 2025

inotify_add_watch() follows symlinks, and returns the current watch descriptor when adding a patch twice. So when doing "watch dir" and "watch link" (or reverse) second watch is basically a no-op; yet it's still registered as a "separate" watch, and would panic on removing the second.

The solution is to make the second Add() a no-op. This is also what kqueue does, and what happens if you watch the same path twice.

On illumos watching a symlink currently means registering double watches; this is a separate bug that should be fixed.

Fixes #652
Fixes #662

inotify_add_watch() follows symlinks, and returns the current watch
descriptor when adding a patch twice. So when doing "watch dir" and
"watch link" (or reverse) second watch is basically a no-op; yet it's
still registered as a "separate" watch, and would panic on removing the
second.

The solution is to make the second Add() a no-op. This is also what
kqueue does, and what happens if you watch the same path twice.

On illumos watching a symlink currently means registering double
watches; this is a separate bug that should be fixed.

Fixes #652
Fixes #662
@arp242 arp242 merged commit 520d098 into main Mar 31, 2025
34 of 36 checks passed
@arp242 arp242 deleted the l branch March 31, 2025 09:33
@obarisk
Copy link

obarisk commented Mar 31, 2025

@arp242 when will we make a new release include this?

project-mirrors-bot-tu bot pushed a commit to project-mirrors/forgejo-as-gitea-fork that referenced this pull request Apr 6, 2025
…tea#7473)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) | require | minor | `v1.8.0` -> `v1.9.0` |

---

### Release Notes

<details>
<summary>fsnotify/fsnotify (github.com/fsnotify/fsnotify)</summary>

### [`v1.9.0`](https://github.com/fsnotify/fsnotify/releases/tag/v1.9.0)

[Compare Source](fsnotify/fsnotify@v1.8.0...v1.9.0)

##### Changes and fixes

-   all: make BufferedWatcher buffered again ([#&go-gitea#8203;657])

-   inotify: fix race when adding/removing watches while a watched path is being deleted ([#&go-gitea#8203;678], [#&go-gitea#8203;686])

-   inotify: don't send empty event if a watched path is unmounted ([#&go-gitea#8203;655])

-   inotify: don't register duplicate watches when watching both a symlink and its target; previously that would get "half-added" and removing the second would panic ([#&go-gitea#8203;679])

-   kqueue: fix watching relative symlinks ([#&go-gitea#8203;681])

-   kqueue: correctly mark pre-existing entries when watching a link to a dir on kqueue ([#&go-gitea#8203;682])

-   illumos: don't send error if changed file is deleted while processing the event ([#&go-gitea#8203;678])

[#&go-gitea#8203;657]: fsnotify/fsnotify#657

[#&go-gitea#8203;678]: fsnotify/fsnotify#678

[#&go-gitea#8203;686]: fsnotify/fsnotify#686

[#&go-gitea#8203;655]: fsnotify/fsnotify#655

[#&go-gitea#8203;681]: fsnotify/fsnotify#681

[#&go-gitea#8203;679]: fsnotify/fsnotify#679

[#&go-gitea#8203;682]: fsnotify/fsnotify#682

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "* 0-3 * * *" (UTC), Automerge - "* 0-3 * * *" (UTC).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yMjIuMSIsInVwZGF0ZWRJblZlciI6IjM5LjIyMi4xIiwidGFyZ2V0QnJhbmNoIjoiZm9yZ2VqbyIsImxhYmVscyI6WyJkZXBlbmRlbmN5LXVwZ3JhZGUiLCJ0ZXN0L25vdC1uZWVkZWQiXX0=-->

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7473
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
Co-committed-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
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.

watcher.Remove crashes on symbolic links
2 participants