Motivation:
The code to filter out ChannelError.eof when reading from the socket and not call fireErrorCaught(...) was broken and so the error was propagated through the pipeline.
Modifications:
- Correctly filter out .eof
- Added testcase
Result:
Correct handling of .eof
Motivation:
In ClientBootstrap we use Int to represent the port but in ServerBootstrap we use Int32. As swift usually always use Int we should just use Int everywhere to represent the port.
Modifications:
Change Int32 to Int for port
Result:
More consistent API
Motivation:
We should better allow access to pthread_t via an withUnsafe function which is more swift-like.
Modifications:
- Add withUnsafePthread and use it
- mark pthread_t as private in Thread.
Result:
More swifty code.
Motivation:
We sometimes used fatalError(...) where we really could just use precondation(...). Beside this we can also consolidate the #if #else code for handling Darwin and Linux differently and so make the code easier to maintain.
Modifications:
- Use precondation
- Consoldate #if #else blocks for Thread
Result:
Cleaner and easier to maintain code.
* Use aliases to reduce duplication and make it easier to maintain.
Motivation:
We used many #if #else blocks which made the code very clumby.
Modifications:
Use aliases and define these in one place.
Result:
Easier to maintain code.
* Comments
* Comments
- This fixes Bootstrap's ChannelOptionStore.applyAll to return a future rather
than synchronously iterating through all the options.
- This is particular important because when a server accepts a child, if the
child channel is on a different event loop then it is possible the
synchronous calls may deadlock (if the child's eventloop happens to be
scheduled with a similar accept sequence).
- I did not tackle also making getOption() async, which means the Channel API
is asymmetric at the moment. That should probably be addressed, potentialy
with synchronous wrappers for API compatibility.
- Fixes: <rdar://problem/37191923> [Omega] Worker tasks fail to close subtasks (many connections in CLOSE_WAIT state)
* Replace usage of Foundation.Thread with our own Thread that just used pthread
* Address comments
* some more docs / comments
* Address comments of cory