Ensure that only the connect or the connection error callback is ever triggered.
merged-on-behalf-of: Leonid Kramer <l-kramer@users.noreply.github.com>
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.
Instead of using waitpid(-1), explicitly waits on all known processes. This is inefficient for large numbers of child processes, but seems to be the only way to ensure to not interfere with other code that uses waitpid().
This mainly affected macOS, which currently uses the polling directory watcher. Since entries were freed during the loop, the remaining keys could point to already freed entries.
Before, the mode GENERIC_WRITE was used. This tells Windows to not
append to the file, but overwrite it normally. This is not the intended
semantics. FILE_APPEND_DATA does what we want.