-
Notifications
You must be signed in to change notification settings - Fork 239
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
implement POSIX polling dirmonitor #1926
base: master
Are you sure you want to change the base?
Conversation
125fcdc
to
319e9d7
Compare
src/api/dirmonitor/polling.c
Outdated
} | ||
|
||
int translate_changes_dirmonitor(struct dirmonitor_internal* monitor, char* buffer, int count, int (*change_callback)(int, const char*, void*), void* data) { | ||
printf("TRANSLATE %i\n", count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO remove
Done some digging around and apparently fstat is bugged on Darwin, would need someone to verify this so the backend will never be selected on MacOS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just some minor inconsistencies and the darwin fstat thing. I will try to test, but do you have anything specific that I should look for?
b504878
to
530908e
Compare
for (size_t i = 0; i < monitor->fd_count; ++i) { | ||
if (monitor->fds[i].fd < 0) | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could fd_count
be raced over?
Same with the fds
structs.
For example:
- We enter
get_changes_dirmonitor
- Main thread enters
add_dirmonitor
add_dirmonitor
needs to allocate new space, so it does, but still doesn't switch it outget_changes_dirmonitor
savesfds
in a registeradd_dirmonitor
switches out the spaces, frees the oldfds
get_changes_dirmonitor
uses thefds
from the register, SIGSEGVs.
// Prepare a new list before switching it to prevent race conditions | ||
struct file_info* old_fds = monitor->fds; | ||
struct file_info* new_fds; | ||
new_fds = malloc(sizeof(*new_fds) * (monitor->fd_count + 1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not too sure about just allocating one more space.
Does what it says on the tin
generic fallback for any POSIX.1-2008 compatible system (though by checking preprocessors it can be lowered down by about a decade)
How it works:
From some minimal testing this seems to work pretty well