Commit Graph
2945 Commits
Author SHA1 Message Date
Norman Maurer 5aff263ad9 Correctly handle ChannelError.eof when reading data from Socket
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
2018-02-12 16:50:34 +01:00
Norman Maurer 5705ce104a Add Channel extension which allows to automatically wrap data into NIOAny 2017-12-28 15:37:06 +01:00
Norman Maurer e70587308a Add echo client example
Motiviation:

We already include an echo server as example but not a client portion. This example sends a message to the server and once it received back the message it will close the connection and exit.

Modification:

Add NIOEchoClient example.

Result:

More examples.
2018-02-12 15:15:35 +01:00
Norman Maurer aa9728b852 Use Int for port to make API more consistent
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
2018-02-12 13:39:01 +01:00
Norman Maurer 18a8467dfe Make parameter naming between connect / bind consistent.
Motivation:

We should have consistent parameter naming.

Modifications:

Use to path: everywhere.

Result:

Consistent naming.
2018-02-12 14:21:07 +01:00
Johannes Weiß e3ea0d7f5d small cleanups 2018-02-05 17:47:04 +00:00
Johannes Weiß 1d7302a189 make future map not allocate if the values are () 2018-02-12 12:46:49 +00:00
Johannes Weiss 01c6e175b7 improve FileRegion tests 2018-02-12 11:52:55 +00:00
Norman Maurer 4f75af6582 Allow access to pthread_t via withUnsafe function.
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.
2018-02-12 12:29:07 +01:00
Norman Maurer 0b5d59fd25 Consolidate #if #else blocks and use precondition
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.
2018-02-12 09:21:14 +01:00
Norman Maurer b09c1598af Fix testcase which was not correctly updated as part of 845d9ee8e95e8ba61e550a26b0a70d59ee98c97d 2018-02-12 08:39:38 +01:00
Norman Maurer a8f0dcf0f5 Use computed property for System.coreCount
Motivation:

We should use a computed property to be more swifty.

Modifications:

Replace function with computed property

Result:

More swifty code.
2018-02-11 13:11:54 +01:00
Johannes Weiß 11a609396d don't blow up when holding onto a ChannelPipeline of a deinitialised Channel 2018-02-09 14:53:09 +00:00
Johannes Weiß ebf351abda implement thread specific values 2018-02-08 17:37:01 +00:00
Cory Benfield 9b0b0f9b51 Add support for SOCK_DGRAM 2018-02-08 14:58:10 +00:00
Cory Benfield 3f357a3c79 Minor cleanups for Swift 4.1 2018-02-08 11:40:45 +00:00
Cory Benfield dfe3fe212a Better readme for release 2018-02-09 12:25:50 +00:00
Johannes Weiss 734904d0f4 clean up the (proto)types for EventLoopFuture
* clean up the (proto)types for EventLoopFuture

* Remove more unnecessary parens
2018-02-09 16:03:28 +00:00
Norman Maurer 17b5fd58e4 Use aliases to reduce duplication and make it easier to maintain.
* 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
2018-02-09 16:56:52 +01:00
Norman Maurer e1f015aa07 Remove out of date to do.
Motivation:

TODO is not valid anymore.

Modifications:

Remove it.

Result:

No missleading comment anymore.
2018-02-09 15:03:46 +01:00
Norman Maurer 3bfdd3f55b Adapt git template that is also used by Netty 2018-02-09 12:19:12 +01:00
Norman Maurer 49b0af924d Add docs for Selector
* Add docs for Selector

* comments
2018-02-08 19:36:26 +01:00
Daniel Dunbar 41bf7278f8 [NIO] Fix setOption() to be async.
- 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)
2018-02-08 09:21:40 -08:00
Norman Maurer 995177fbc6 Support setting Thread affinity and use it with EventLoopGroups 2018-02-06 16:08:57 +01:00
Cory Benfield ce7b0c52ce Add a CompositeError type 2018-02-08 13:12:30 +00:00
Cory Benfield 08817ded87 Remove copy in withMutableSockAddr 2018-02-08 12:52:03 +00:00
Cory Benfield 41f3abe366 BaseSocketChannel should use NIOAny 2018-02-08 11:42:01 +00:00
Cory Benfield d216f6a7e9 Add public constructor for AddressedEnvelope 2018-02-08 11:21:55 +00:00
Johannes Weiß b26bfce61e detach threads so we don't leak them 2018-02-08 10:57:51 +00:00
Cory Benfield 453b87ff5e Fixup thread unsafety 2018-02-08 10:57:46 +00:00
Cory Benfield 3768e2a2b9 Don't allow registration on shutting down loops 2018-02-08 10:25:47 +00:00
Norman Maurer 71f179e63b Change Thread to be internal as we not expose it to the user 2018-02-08 09:26:53 +01:00
Johannes Weiss 8ed8f73d9a remote now unnecessary swiftw script 2018-02-07 17:31:39 +00:00
Johannes Weiss 755ea5aedc non-blocking file IO 2018-02-07 17:25:45 +00:00
Johannes Weiß 676453c8b9 trivial: fix RecvByteBufferAllocator typos 2018-02-06 18:24:48 +00:00
Johannes Weiss e21432e955 don't leak open FileRegions (fds) in HTTP client 2018-02-06 16:35:35 +00:00
Johannes Weiß 9c73c9deb9 fix flaky ChannelTests.testHalfClosure 2018-02-06 15:24:01 +00:00
Johannes Weiß 32bb597c24 remove Int extension we do not need 2018-02-06 12:30:27 +00:00
Norman Maurer e1bf447a9a Replace usage of Foundation.Thread with our own Thread that just used…
* Replace usage of Foundation.Thread with our own Thread that just used pthread

* Address comments

* some more docs / comments

* Address comments of cory
2018-02-06 11:45:57 +01:00
Daniel Dunbar 74a10d8137 [SocketAddress] Add .port accessor.
- This is for convenience in clients which want to get the assigned port, when
   OS-assigned ports are used.
2018-02-05 12:42:57 -08:00
Johannes Weiss 66a26cee57 fix http parser updater: didn't process header file 2018-02-02 19:40:42 +00:00
Cory Benfield 2630d583cd Happy Eyeballs! 2018-02-02 17:26:51 +00:00
Cory Benfield 1ae2c97903 Make SocketAddress equatable 2018-02-02 10:28:11 +00:00
Cory Benfield b3ed4eee1b Preparatory refactor of PWM for datagrams 2018-01-31 16:21:13 +00:00
Tom Doron a4b9862711 fix doc generation to include deleted files
motivation: in git 2.0 deleted files are ignored unless --all is specified

```
warning: You ran 'git add' with neither '-A (--all)' or '--ignore-removal',
whose behaviour will change in Git 2.0 with respect to paths you removed.
Paths like 'docs/current/NIOOpenSSL/Classes.html' that are
removed from your working tree are ignored with this version of Git.
```

changes: use git add -all docs to includes removeals
2018-01-31 11:12:59 -08:00
Johannes Weiss 07ff34087a make IOResult equatable 2018-01-31 18:02:32 +00:00
Cory Benfield 5ce3ac2142 Add socket address helpers 2018-01-31 15:43:45 +00:00
Johannes Weiss ce1d4bb7d8 fix ByteBuffer docs of withUnsafeWritableBytes 2018-01-31 14:15:22 +00:00
Johannes Weiß 05047ec852 switch to Jazzy's fullwidth theme 2018-01-31 10:53:52 +00:00
Johannes Weiß 8c7105f0a3 remove lazy create todo 2018-01-31 10:58:09 +00:00