Uses a buffer size that is more reasonable for modern transfer speeds, while still providing enough granularity for cancellation. This heavily reduces the computational overhead on SSD drives.
Previously, the loop logic would simply retry the wait until the given timeout was actually reached (or an event got received), which could be forever. This change makes sure that after an interrupt the higher level code will get a chance to run to possibly handle the effects of the signal.
This is a fix for vibe-d/vibe-core#205.
fstat doesn't work correctly on Windows, possibly due to a bad C header translation on Druntime. Also switches to _lseeki64/lseek64 to avoid 32-bit file length limitations on 32-bit systems.
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);
```
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.