Commits on Aug 15, 2019
… `CNIOAtomics.h` (#1111) The inclusion of `cpp_magic.h` in `CNIOAtomics.h` is unnecessary and pollutes the namespace of anyone else importing the header. NIO now also requires Swift 5, which itself will not be built with a Clang too old to understand `_Nonnull`. Note: Removing the extra import of cpp-magic.h required moving it to the src/ directory to avoid complaints about its inclusion (or lack thereof) in the module's umbrella header.
Commits on Aug 13, 2019
The `atomic_flag` wrappers (structure, `create` helper, and `destroy` helper) are not referenced from anywhere else in the NIO source tree; they can not be invoked, and appear to serve no purpose. Under sufficiently strict compiler settings, they even cause errors due to the functions lacking prototype declarations.
Commits on Feb 6, 2019
…ut before `fcntl()` on macOS. (#807) Motivation: A race condition occurs when a socket is closed from the remote end after `accept()` returns it, but before `fcntl(F_SETFL, F_SETNOSIGPIPE)` is invoked. This causes the `fcntl()` call to fail with `EINVAL` ("The socket has been shut down."). This currently triggers an assertion failure. As the race depends on the remote and can be easily demonstrated (using `nmap` is a good way to set it off), the assertion is semantically invalid (`EINVAL` is not programmer error). Additionally, errors reported by `fcntl()` in general are being ignored when not asserted. Modifications: The race is avoided by treating `EINVAL` as a normal error while retaining the existing behavior for all other error cases. Both uses of `fcntl()` to disable `SIGPIPE` now properly report errors. Result: `Posix.accept()` and `Posix.socket()` may now potentially throw additional errors. It is no longer possible to crash a debug server by running `nmap` against it.
Commits on Jan 29, 2019
* Add cancel notification to RepeatedTask Motivation: When cancelling a RepeatedTask, it is often desirable to wait until any still in-progress execution of the task is finished - for example, to know when a periodic state save is done before shutting down. The current API provides no easy way to perform such a wait. With this addition, repeating tasks can report completion of a cancellation request regardless of in what state the task was in when the request was issued. Modifications: A default-nil parameter is added to EventLoop.scheduleRepeatedTask(), to which a promise can be provided; the promise will be fulfilled at the time of the task's cancellation, plus any time required for the task to complete running if it was cancelled during execution. The promise is signaled even if the cancellation is the result of the task throwing an error. A default-nil paramter is also added to RepeatedTask.cancel(), to which a second promise can be passed. This promise is fulfilled under the same conditions as the first, even if the first was not given; neither of the promises is dependent upon the other and both are fulfilled at the same time if provided. Further calls to cancel() with different promises will result in fulfillment of each of those promises as well. Result: The observed behavior of RepeatedTask.cancel() now optionally includes deterministic knowledge of when the task is no longer executing or scheduled to be executed. The API changes are designed to be additive in form, but the function signatures do change. Source compatibility is maintained; binary compatibility is not.