Commit Graph

650 Commits

Author SHA1 Message Date
Ariel Abreu
ed45525ac4
Use kprintf rather than logging to a file 2022-02-26 01:14:07 -05:00
Ariel Abreu
9b4eecbd88
Don't check for new events if KEVENT_FLAG_ERROR_EVENTS is given
We were dropping events before because libdispatch calls kevent with this flag to update a knote without checking for new events; when it did that and we handed it some new events, it would ignore them since they didn't contain `EV_ERROR`, which meant those events were lost forever.
2022-02-25 16:15:41 -05:00
Ariel Abreu
76d8aa3dce
Only process EV_DISPATCH and EV_ONESHOT when we get a valid event
If the copyout callback for a filter indicates that the event should be ignored/dropped, we should not process EV_DISPATCH or EV_ONESHOT, as this would lead to missing actual events in the future.

Some filters (e.g. EVFILT_PROC) do specifically want to process EV_ONESHOT even when dropping an event, so this also introduces a special filter ID (EVFILT_DROP_POSTPROCESS) that enables the old behavior for individual events. Additionally, rather than just using `0` as a special filter ID, this commit introduces EVFILT_DROP (to be clear about its meaning).
2022-02-25 16:12:17 -05:00
Ariel Abreu
bcef9ea04b
Handle no-event case in copyin for EVFILT_MACHPORT 2022-02-20 01:03:17 -05:00
Ariel Abreu
532529e49c
Implement EVFILT_PROC with darlingserver 2022-02-12 00:38:04 -05:00
Ariel Abreu
975d7457cd
Implement EVFILT_MACHPORT with darlingserver
See the darlingserver repo for the majority of the logic behind the new implementation.

TODO: libkqueue needs proper kevent_qos support in order to be able to use the data_out parameter passed in to kevent_qos calls (which is what *should* be passed as the default buffer to use when ext[0] is not available in EVFILT_MACHPORT).
2022-02-10 13:23:16 -05:00
Ariel Abreu
b395f5bf0d
Disable EVFILT_{MACHPORT,PROC}
These need to be reimplemented for darlingserver. This commit simply replaces them with code that prints "TODO" and then aborts.
2022-01-28 00:10:59 -05:00
Ariel Abreu
3f76738619
Handle race condition when waiting for events
If multiple threads are waiting on the same kqueue, they'll all be woken up at the same time, however only one can acquire the lock at a time. The one that acquires it first gets to consume some events from the kqueue while everyone else waits. But, after they're done and they release the lock, the next person will have *less events available*. We were previously neglecting to check for this and trying to consume more events than were available (leading to some nasty deadlocks with certain events like EVFILT_USER).
2020-10-07 12:50:08 -04:00
Ariel Abreu
9a94fadf15
Workaround an issue caused by a flag
When we pass back EV_VANISHED to libdispatch, it thinks we're telling it the source vanished (because that's really what it means) and it explodes
2020-10-06 08:28:31 -04:00
Ariel Abreu
3c34d903b4
Initial update to clean up include directories
"initial" because there might some additional modifications necessary later on
2020-05-14 12:57:41 -04:00
Lubos Dolezel
0bed997345 Add internal kqueue_dup() 2020-04-27 11:27:13 +02:00
Lubos Dolezel
2c2d5cfd06 Provide kqueue_atfork() 2020-03-31 11:22:23 +02:00
Lubos Dolezel
d534499fdb Prevent fd leaks in EVFILT_READ/WRITE 2020-03-22 19:17:58 +01:00
Lubos Dolezel
cf2248b1ed Crash fix 2020-03-06 17:28:12 +01:00
Lubos Dolezel
24c025368b Enforce non-zero timer timeout (0 means disabled) 2020-02-23 23:25:18 +01:00
Lubos Dolezel
8c9ce7a18b Fix resetting timer deadline (darlinghq/darling#688) 2020-02-23 22:30:02 +01:00
Luboš Doležel
d7ea5ec719
Merge pull request #2 from TheBrokenRail/patch-1
Move LKM to src/external
2020-02-17 09:02:20 +01:00
TheBrokenRail
6fa9c41c9c
Move LKM to src/external 2020-02-16 13:58:47 -05:00
Lubos Dolezel
6bf29621b1 Build fix 2020-01-28 15:49:15 +01:00
Lubos Dolezel
c01ee564d8 Small change for newer XNUs 2020-01-27 19:26:42 +01:00
Andrew Hyatt
ae2fbcd28e
Allow i386 or x86_64 only builds 2019-08-13 14:11:14 -04:00
Lubos Dolezel
7ac3d4fbb1 Fixes for kqueue timers (darlinghq/darling#420) 2018-11-07 20:25:45 +01:00
Lubos Dolezel
2c12e86fc6 More fixes 2018-09-06 10:33:55 +02:00
Lubos Dolezel
1d627ad694 Attempt to fix darlinghq/darling#420 2018-08-27 11:30:03 +02:00
Lubos Dolezel
f411d4553d Prevent leaking of machport/proc/signal fds across execve() 2017-07-13 20:12:22 +02:00
Lubos Dolezel
22005641d9 Adapt to new EVFILT_MACHPORT LKM API 2017-07-13 12:20:42 +02:00
Lubos Dolezel
3605093fd5 Fixes for launchd 2017-07-10 16:02:01 +02:00
Lubos Dolezel
284c5896a6 Fix build on i386 2017-04-29 19:39:41 +02:00
Lubos Dolezel
fa8dc2dbbd Make libkqueue fat 2017-04-29 19:27:46 +02:00
Lubos Dolezel
0e5c51eeae Bug fixes for launchd 2017-04-24 16:52:19 +02:00
Lubos Dolezel
b5750589d7 Implement EVFILT_FS (partially) 2017-04-21 09:54:13 +02:00
Lubos Dolezel
9f7cfeaef7 Add support for EVFILT_PROC 2017-04-20 00:04:06 +02:00
Lubos Dolezel
903c4f4199 Fix vnode incorrectly working with inotify 2017-04-18 17:08:13 +02:00
Lubos Dolezel
2451eea5e8 Add EV_MACHPORT support 2017-04-18 17:07:59 +02:00
Lubos Dolezel
9e2eb6157b Use special close() variant for libkqueue to avoid deadlocks 2017-04-16 18:03:21 +02:00
Lubos Dolezel
5a3f37bc94 Initial code to support new EV_TIMER fflags (absolute time, nanosecond time etc.) 2017-04-16 12:11:43 +02:00
Lubos Dolezel
ed84e41217 Implement kevent64() (resolves darlinghq/darling#288) 2017-04-10 15:13:14 +02:00
Lubos Dolezel
53606dffd8 Kill a message() in CMakeLists.txt 2017-03-27 11:19:55 +02:00
Lubos Dolezel
3a20121940 Support modifying existing knotes 2017-03-02 14:51:05 +01:00
Lubos Dolezel
61ab68ad6d Reference count kqueues, improve kqueue_close() 2017-03-01 18:57:46 +01:00
Lubos Dolezel
67c22f96ce dup() all fds used on Linux otherwise we cannot add the same descriptor multiple times into epoll 2017-03-01 18:30:18 +01:00
Lubos Dolezel
87619c6fed Build fixes 2017-03-01 17:48:57 +01:00
Lubos Dolezel
393d8ab599 Several more libkqueue fixes 2017-03-01 17:34:02 +01:00
Lubos Dolezel
a2523329a0 Improve bad fd handling to pass the kqueue() quality test in libevent 2017-03-01 14:53:55 +01:00
Lubos Dolezel
e7f550d34d kqueue -> kqueue_impl, kevent -> kevent_impl 2017-02-28 17:51:54 +01:00
Lubos Dolezel
7dbf79587a Work on build after libc upgrade 2017-01-25 16:09:05 +01:00
Lubos Dolezel
645e2b36c0 Build .dylibs 2017-01-17 14:35:24 +01:00
Luboš Doležel
0728438e9c Merge pull request #1 from ahyattdev/master
Install manpage
2016-11-22 22:54:12 +01:00
Andrew Hyatt
80049b7780 Install manpage 2016-11-22 10:29:29 -08:00
Lubos Dolezel
3a45b91e45 workarounds for thread local storage 2016-11-06 20:35:42 +01:00