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.
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.
The events reported always use the canonical path, which broke the relative path logic. TO counter this, the canonical path is now determined explicitly.
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.
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.
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.
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.
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.
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.
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.
On macOS it could happen that both, onConnect and onConnectError, were triggered, resulting in seemingly overlapping connection attempts when they really were sequential. This in turn triggered a connection error leak test in vibe-core.
Now using only the write-ready flag plus the reported socket error status to determine failed connections, guaranteeing a single call back.
Malloc should not force '@safe' or '@nogc' on constructors which are not.
For example, TaskPool's ctor is not '@nogc' but was assumed as such
thanks to the delegate cast happening in malloc.
Likewise, the ctor or the arguments might not be '@safe',
or any other attributes, but they were be mistakenly marked as such.
Depending on the timing of starting and finishing DNS queries, `Thread.join` could be called on an instance that had already been `destroy`ed. To avoid this, the thread instance is now explicitly set to null, as well as resetting the "done" field to avoid redundant work for unused slots.
See vibe-d/vibe.d#2378.
std.parallelism.Task.executeInNewThread leaks the thread's resources instead of reusing it in later calls. As a workaround, this commit starts a new thread for every lookup and properly tears it down afterwards. At a later point, this code should be changed to reuse the thread(s), if possible, to avoid the startup overhead.
Integrates the contents of StaticProcesses into PosixEventDriverProcesses to fully hide it form the Windows build. It also changes lockedProcessInfo to be a non-template function, as that lead to a linker error on macOS.
It turns out that in a heterogeneous process where other parts of the code may start processes or threads and may be waiting for those to finish, it is not realistic to rely on signalfd or even SIGCHLD in general to get notified about child process exits. The only solid way appears to be to start a separate waiter thread that uses waitid/waitpid to wait for exited child processes in a blocking way.
This also fixes the hanging vibe.core.process test in vibe-core with DMD 2.087.x.