-
-
Notifications
You must be signed in to change notification settings - Fork 146
FSEvents backend for tup monitor
#531
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
Open
LoganDark
wants to merge
6
commits into
gittup:master
Choose a base branch
from
LoganDark:fsevents-monitor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
de3311b
FSEvents backend for tup monitor
LoganDark ee61946
signal lock release with ftruncate on macOS
LoganDark d2c6643
use TUP_LOCKING variable to select flock backend
LoganDark 3016b3e
fsevents: prevent autoupdate bomb on monitor reactivity
LoganDark 4e1a401
fsevents: always do_scan on yield, drop events_occurred gate
LoganDark 5c1ec19
scanner: detect renames by inode to preserve node identity
LoganDark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,11 @@ | ||
| include_rules | ||
|
|
||
| ifneq ($(TARGET),win32) | ||
| ifeq ($(TARGET),macosx) | ||
| : foreach flock.c |> !cc |> | ||
| else | ||
| : foreach fcntl.c |> !cc |> | ||
| endif | ||
| else | ||
| : foreach lock_file.c |> !cc |> | ||
| endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| /* vim: set ts=8 sw=8 sts=8 noet tw=78: | ||
| * | ||
| * tup - A file-based build system | ||
| * | ||
| * Copyright (C) 2011-2026 Mike Shal <marfey@gmail.com> | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License version 2 as | ||
| * published by the Free Software Foundation. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License along | ||
| * with this program; if not, write to the Free Software Foundation, Inc., | ||
| * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| */ | ||
|
|
||
| /* BSD flock(2) backend. Used on macOS because kqueue EVFILT_VNODE with | ||
| * NOTE_FUNLOCK can detect flock releases (but not fcntl lock releases), | ||
| * enabling event-driven lock coordination in the monitor. | ||
| */ | ||
|
|
||
| #define _ATFILE_SOURCE | ||
| #include "tup/flock.h" | ||
| #include <stdio.h> | ||
| #include <fcntl.h> | ||
| #include <unistd.h> | ||
| #include <errno.h> | ||
| #include <sys/file.h> | ||
|
|
||
| int tup_lock_open(int basefd, const char *lockname, tup_lock_t *lock) | ||
| { | ||
| int fd; | ||
|
|
||
| fd = openat(basefd, lockname, O_RDWR | O_CREAT, 0666); | ||
| if(fd < 0) { | ||
| perror(lockname); | ||
| fprintf(stderr, "tup error: Unable to open lockfile.\n"); | ||
| return -1; | ||
| } | ||
| *lock = fd; | ||
| return 0; | ||
| } | ||
|
|
||
| void tup_lock_close(tup_lock_t lock) | ||
| { | ||
| if(close(lock) < 0) { | ||
| perror("close(lock)"); | ||
| } | ||
| } | ||
|
|
||
| int tup_flock(tup_lock_t fd) | ||
| { | ||
| if(flock(fd, LOCK_EX) < 0) { | ||
| perror("flock LOCK_EX"); | ||
| return -1; | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
| /* Returns: -1 error, 0 got lock, 1 would block */ | ||
| int tup_try_flock(tup_lock_t fd) | ||
| { | ||
| if(flock(fd, LOCK_EX | LOCK_NB) < 0) { | ||
| if(errno == EWOULDBLOCK) | ||
| return 1; | ||
| perror("flock LOCK_EX|LOCK_NB"); | ||
| return -1; | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
| int tup_unflock(tup_lock_t fd) | ||
| { | ||
| if(flock(fd, LOCK_UN) < 0) { | ||
| perror("flock LOCK_UN"); | ||
| return -1; | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
| int tup_wait_flock(tup_lock_t fd) | ||
| { | ||
| /* Not used on macOS - the fsevents monitor uses kqueue | ||
| * NOTE_FUNLOCK/NOTE_ATTRIB for event-driven lock notification | ||
| * instead of polling. It is not possible to achieve this API on | ||
| * macOS without polling. | ||
| */ | ||
| (void)fd; | ||
| fprintf(stderr, "tup internal error: tup_wait_flock called on macOS\n"); | ||
| return -1; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| include_rules | ||
|
|
||
| : $(TUP_MONITOR).c |> !cc |> | ||
| : foreach $(TUP_MONITOR).c common.c |> !cc |> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.