Commit graph

567 commits

Author SHA1 Message Date
Daniel Graczer a462db4e04 suppressing socketStream warnings during shutdown initiated by SIGINT 2020-08-31 13:58:20 +02:00
Geod24 a027c233c2 Add support for DMD 2.094 -preview=in switch
This will allow users to use -preview=in as soon as it's released.
Of course this had to uncovered a DMD bug in the process.
2020-08-31 05:00:03 +02:00
Andrej Mitrovic 6f62236b2d DNS allocateHandle(): Don't return handle in use
This is a second attempt at fixing the issue originally
mentioned in PR #152.

This will allocate a new handle if all of them are in use.
2020-08-31 02:21:05 +02:00
Tobias Pankrath 1fcc941b1f Improve documentation w.r.t to concurrent writes/reads 2020-08-31 02:19:53 +02:00
Andrej Mitrovic ac4aec341e dns: Set the result to null in cancelLookup()
When lookupHost() is called the handle returned
from allocateHandle() might be a reused handle.

The delegate will be cleared, but the result might
still be there and the assert in lookupHost()
will fail:

```
assert(!m_lookups[handle].result);
```
2020-08-19 08:03:45 +02:00
Márcio Martins deaebb18d8 Fix host lookups hanging with concurrency 2020-08-11 10:42:36 +02:00
Geod24 862b5d470c posix/dns: Fix SEGV on Musl when an error happens
When an error happens, the 'struct addrinfo' (ai)
passed to 'passToDNSCallback' can be 'null'.
It end up being passed to 'freeaddrinfo'.
With glibc, or on OSX, it is okay to pass a 'null'
pointer to 'freeaddrinfo', however this will cause
a SIGSEGV on Musl.
The standard defines that 'freeaddrinfo' must accept
what was given to 'getaddrinfo', and 'getaddrinfo'
does not accept null pointer, so the musl behavior
is not wrong per se.
2020-08-03 03:04:39 +02:00
Sönke Ludwig 9e94195bd4 Bump meson version number. 2020-05-28 18:31:12 +02:00
Sönke Ludwig ab829efc7c Rearm the CFFileDescriptor before each CFRunLoop run.
Instead of rearming from within the callback, this enables the callback before the event loop is run and before the kqueue is cleared. This at least heavily reduces the cases where the CFRunLoop hangs instead of reporting a pending kqueue event. For this reason, the safety timeout has been increased to 5 seconds.
2020-05-28 16:43:20 +02:00
Sönke Ludwig f99ba6db49 Bump meson version number. 2020-05-27 21:27:08 +02:00
Sönke Ludwig 68cbade330
Merge pull request #149 from vibe-d/fseventstream_fixes
FSEventStream fixes
2020-05-27 21:13:19 +02:00
Sönke Ludwig eb9c49a577 Fix the FSEvent rename logic.
It turned out to be impossible to determine the source and target names for a rename operation, so the actual existence of the file has to be used.
2020-05-27 17:58:28 +02:00
Sönke Ludwig 8695b4d32c Ignore sentinel events for the FSEvents watcher.
This caused the watcher to be endlessly recreated in rapid succession.
2020-05-27 17:57:27 +02:00
Sönke Ludwig 9120982bed Fix watching symlinked paths with FSEvents.
The events reported always use the canonical path, which broke the relative path logic. TO counter this, the canonical path is now determined explicitly.
2020-05-27 17:56:28 +02:00
Sönke Ludwig a77f626b97 Implement an alternative workaround for CFRunLoop hangs.
Limits the timeout for the CFRunLoop call to one second, after which kqueue will be re-checked again manually, guaranteeing that if a hang occurs, it will be resolved after at most one second.
2020-05-27 12:45:53 +02:00
Sönke Ludwig a9344c8490 Revert "Work around possible hang of CFRunLoop with pending kqueue events."
This reverts commit decbe7f6bd.

Using level triggered events resulted in 100% CPU usage, because sockets receive a constant write-ready event. They register themselves with the event loop only once in the beginning for efficiency reasons and thus may receive these events without any active waiters.

In case of kqueue it would be possible to register dynamically only when waiting, without a big performance impact, but in case of the epoll API this would result in am excessive growth of kernel calls.
2020-05-27 12:29:44 +02:00
Sönke Ludwig fb62ba3ff2 Bump meson version number. 2020-05-25 20:18:51 +02:00
Leonid Kramer d52e065605
Merge pull request #148 from vibe-d/cfrunloop_fixes
CFRunLoop fixes
2020-05-25 18:57:28 +02:00
Sönke Ludwig 194667a99f Fix reported status for disconnected message based Unix sockets.
Was reporting IOStatus.ok for a connection that was disconnected, possibly resulting in an endless loop (or recursion) of trying to read another (apparently zero sized) packet.
2020-05-25 14:37:55 +02:00
Sönke Ludwig 167745efb0 Fix CFRunLoop selection in multi-threaded scenarios.
CFRunLoopGetMain returns the main thread's run loop, as opposed to the one belonging to the calling thread.
2020-05-25 14:36:29 +02:00
Sönke Ludwig fd462d89f1 Bump meson version number. 2020-05-25 11:31:42 +02:00
Sönke Ludwig 72cb27bb93
Merge pull request #147 from vibe-d/fix_cfrunloop_hang
Work around possible hang of CFRunLoop with pending kqueue events.
2020-05-25 11:31:12 +02:00
Sönke Ludwig decbe7f6bd Work around possible hang of CFRunLoop with pending kqueue events. 2020-05-25 10:31:43 +02:00
Sönke Ludwig 307542ff82 Bump meson version number. 2020-05-23 21:29:34 +02:00
Leonid Kramer 9ad2969ee2
Merge pull request #146 from vibe-d/cfrunloop
CFRunLoop support and FSEvent directory watcher for macOS
2020-05-23 21:22:27 +02:00
Sönke Ludwig 8e84af1483 Test CFRunLoop on macOS. 2020-05-23 17:41:02 +02:00
Sönke Ludwig 49b2aff0c2 Move loop modules back to the posix package to work around compiler errors.
Older DMD frontend versions don't handle "package" protection within derived classes correctly.
2020-05-23 17:41:02 +02:00
Sönke Ludwig 0cdfe793af Implement an FSEvents based watcher for macOS.
Provides efficient and low latency directory watching on macOS when using the CFRunLoop based event loop.
2020-05-23 17:41:02 +02:00
Sönke Ludwig 6e5fb79c62 Work around platform differences in the directory watcher test.
- Drops all events that happen before any changes are made (FSEventStream reports events from the past to a certain degree)
- Tests the same file twice in a row, since FSEventStream might coalesce events and report bogus changes
- Allows "modified" instead of "added" events, because FSEventStream does not allow to distinguish in some cases
2020-05-23 17:40:57 +02:00
Sönke Ludwig e28450f9f5 Implement a CFRunLoop based event loop.
This enables efficient integration of the kqueue based I/O processing with Apple OS based UI apps.

On top of that, an FSEvent based directory watcher can now be implemented to replace the inefficient generic watcher that is used on macOS right now.
2020-05-22 16:02:45 +02:00
Sönke Ludwig 4b1afa8d6c Allow to inherit from the kqueue loop implementation. 2020-05-22 09:59:25 +02:00
Sönke Ludwig aa3659fca6 Handle redundant cancelReceive calls gracefully and clean up the callback. 2020-05-22 09:59:25 +02:00
Sönke Ludwig 1f9a99a805 Fix potential access of an invalid waiter queue. 2020-05-22 09:59:25 +02:00
Sönke Ludwig 2f03f8dd42 Move Posix event loop implementations to their own package. 2020-05-19 10:10:15 +02:00
Sönke Ludwig 751091a2bd
Merge pull request #145 from vibe-d/fixes
Remove invalid assertion.
2020-05-18 16:37:44 +02:00
Sönke Ludwig b0ed2389fa Remove invalid assertion.
Since file descriptors are now identified using their validation counter, it is a valid operation to invalidate a slot that is still referenced.

This fixes a related test failure in vibe-core.
2020-05-18 15:09:34 +02:00
Sönke Ludwig 555d1e8867 Bump meson version. 2020-05-17 15:03:35 +02:00
Sönke Ludwig bace6c6c80
Merge pull request #144 from vibe-d/async_fixes
Fix API issues resulting in blocking the main thread
2020-05-12 10:57:18 +02:00
Sönke Ludwig 85dc8d54e6 Make file and pipe closing asynchronous.
CloseHandle can block for extended periods of time in certain cases, causing the whole thread to be blocked otherwise.
2020-05-12 09:47:06 +02:00
Sönke Ludwig 86ee5c9477 Remove FileChange.isDirectory.
isDir can be a huge performance issue when watching a network based directory and can effectively block the thread almost completely in case of frequent file changes. This does mean than high-level code now needs to perform the check manually, if required, and the free information provided by inotify goes unused.
2020-05-11 19:30:40 +02:00
Sönke Ludwig d7657b54e8 Move shared thread pool functionality to a separate module. 2020-05-11 17:09:14 +02:00
Sönke Ludwig a27abdb956 Fixup. 2020-05-11 17:09:14 +02:00
Sönke Ludwig 8c2790c66e
Merge pull request #140 from Cogitri/meson
Add support for building with meson
2020-05-11 17:06:42 +02:00
Sönke Ludwig 02aef78ac8
Merge pull request #142 from vibe-d/handle_robustness
Improve handle robustness
2020-05-11 17:06:16 +02:00
Sönke Ludwig 496e99c3b4 Make the API robust against using invalid handles. Fixes #105.
Introduces a "validationCounter" field for all handle types that gets incremented (at least) whenever an OS file descriptor/handle gets invalidated or re-allocated. This way, an old eventcore handle to a reused OS handle can always be distinguished from the current one to avoid interference.
2020-05-11 17:05:53 +02:00
Sönke Ludwig 768c6cf4c8
Merge pull request #143 from Geod24/deprecations
Fix a printf format deprecation triggered by 2.092
2020-05-11 17:03:01 +02:00
Sönke Ludwig 6372b4aabf
Merge pull request #141 from kubo39/patch-pipe-cloexec
Set close-on-exec flag for PipeFD
2020-05-11 11:23:37 +02:00
Geod24 3888f9f6a0 Fix a printf format deprecation triggered by 2.092 2020-05-11 11:14:03 +09:00
Hiroki Noda e6660486a3 Set close-on-exec flag for PipeFD 2020-04-09 21:36:19 +09:00
Rasmus Thomsen 409f9cac73 Add support for building with meson 2020-03-26 07:58:02 +01:00