Commit Graph

24 Commits

Author SHA1 Message Date
Johannes Weiss d68f9d1f8e make NIOTS compile on Linux (#29)
Motivation:

NIOTS will not work on Linux but we can at least make it not fail
compilation when compiled on Linux. That way consumers of the API can
depend on NIOTS but make sure they only use NIOTS when wrapped in a
`#if canImport(Network)` block.

Modification:

Guard everything by `#if canImport(Network)`

Result:

This package will now build on Linux (without providing any useful
code).
2019-03-25 16:49:35 +02:00
Cory Benfield 501197f000 Correctly avoid branch dependency. (#31)
Motivation:

When entering convergence we incorrectly specified a branch dependency
for something that is actually a tag.

Modifications:

- Remove branch dependency, use from: instead.

Result:

Users can use this repo!
2019-03-25 09:44:58 +00:00
Johannes Weiss 1d0cb1040e
don't retain everything until connect timeout expires (#30)
Motivation:

Previously we would use the combination of DispatchQueue.asyncAfter and
a DispatchWorkItem for the connect timeout. If the connection succeeded
we would just cancel the DispatchWorkItem. Unfortunately that will still
keep everything that's captured in the DispatchWorkItem alive until the
deadline has come (because DispatchWorkItem is just a dumb wrapper over
a closure).

Modifications:

use a DispatchSource of type timer source instead.

Result:

- we won't keep the ELG/EL/Channel/... alive until at least the connect
  timeout expires.
- fixes #28
2019-03-22 15:40:02 +00:00
Cory Benfield e1685ae770 Prepare for convergence. (#27)
Motivation:

Once every few thousand years, an event called syzygy (or "convergence")
occurs in our solar system. When these events occur, the fabric of spacetime
becomes thin, allowing reflections of a possible future to appear in our
reality.

This gives a few brave souls the opportunity to experience a future: a
possibility of the way the universe may one day be. But be warned: to
toy with causality is to risk unbearable pain and suffering. Only the
bravest of souls should look too closely at these shadows of the future.

Modifications:

- Chose a firm anchor point in the SwiftNIO timeline.
- Removed the braces that kept time travellers safe.
- Said a quiet prayer.

Result:

Opportunity.
2019-03-15 14:48:05 +00:00
Johannes Weiss 15fe53093c update to latest NIO 2 (#26)
Motivation:

Code should compile and have the latest NIO 2 API.

Modifications:

- rename `ctx` to `context`
- apply all fixits

Result:

compiles again
2019-02-26 13:01:17 +00:00
Cory Benfield 971a6a37ec Bring patches up to new NIO 2 master (#23) 2019-02-26 12:13:54 +00:00
Cory Benfield 72f0815335 Support setting enablePeerToPeer. (#22) (#24)
Motivation:

Some users may wish to use peer-to-peer networking with bonjour.

Modifications:

Expose peer-to-peer networking via a new channel option.

Result:

Users will be able to use peer-to-peer networking

(cherry picked from commit e9c1e41fd1)
2019-02-11 13:12:18 +01:00
Johannes Weiss 4587afdf46 port to latest NIO 2 APIs (#20)
Motivation:

Compiling code is good so let's make it compile again with the latest
NIO APIs.

Modifications:
- made NIOTS use `_NIO1APIShims`
- clicked 'Fix All' a couple of times to adjust the API

Result:
Code compiles again
2019-01-22 15:38:13 +00:00
Johannes Weiss 9fa52bd443 use to NIO 2 (from master branch) and Swift 5 (#18)
Motivation:

SwiftPM from Swift 5.0 brings targets that only support certain systems
which is really handy for this package as it only support macOS 10.14+
and iOS/tvOS 12+

Modifications:

- made use of the Swift 5.0 manifests which can have restrictions on the
  supported platforms
- adapted to NIO 2

Result:

- better development story
- using the latest & greatest
2019-01-18 13:03:21 +00:00
Cory Benfield ea5ba9bd25 Don't transition to .registered unless registration succeeds. (#19)
Motivation:

In some cases, such as when an event loop has been shutdown, channel
registration may fail. In these cases, we would incorrectly attempt to
deregister the channel, which would fail (and in debug builds, assert).
Really, we shouldn't transition into .registered until we know that we have,
in fact, registered.

However, we need to be cautious: we don't want to register unless we
believe we're in an acceptable state to register.

Modifications:

Updated the state enum to perform the registration at the correct
part of the state change function.

Result:

Harder to crash in debug mode
2019-01-08 21:40:57 +00:00
Cory Benfield fb5d37a1e1 Correctly hop across event loops during child channel setup. (#17)
Motivation:

We were inadvertently modifying the registration information of
NIOTSEventLoop objects from multiple threads, which is very not good.

Modifications:

Add an event loop execute to hop loops.

Result:

Thread safe!
2018-12-06 15:02:08 +00:00
Cory Benfield 1761d4eafa Make Channel.isActive thread-safe. (#16)
Motivation:

Sadly I overlooked the fact that Channel.isActive is supposed to be
safe to call from multiple threads: the implementation here was not.

Modifications:

Store the active state into an Atomic.

Result:

It will be thread-safe to ask if a channel is active.
2018-12-06 12:22:58 +00:00
Cory Benfield 5840333f0a Support opting-out of Network.framework waiting state. (#15)
Motivation:

In some cases users may prefer not to wait for Network.framework to
reattempt connection in the future. Users should be able to opt-out of the
default waiting behaviour in those cases.

Modifications:

- Added WaitForActivity ChannelOption.

Result:

Users can configure channels better.
2018-12-03 11:28:20 +00:00
Cory Benfield 73f758b5da Remove invalid assertion. (#13)
Motivation:

It is possible to receive the dataReceived callback after we've called
cancel, mostly because there may be such a block in place in the queue
before that cancel call fires. We should tolerate that.

Modifications:

Removed the invalid assertion.

Result:

Fewer failures.
2018-11-15 10:47:01 +00:00
Johannes Weiss 833b152a21 better diagnostics if unsupported ChannelOption set (#12)
Motivation:

If the user sets an unsupported ChannelOption we should give the best
diagnostics possible.

Modifications:

Add the ChannelOption type to the error message that it's unsupported.

Result:

Happier users
2018-11-09 17:15:35 +00:00
Cory Benfield a9cece8a6d
Support preconditionInEventLoop. (#11)
Motivation:

In SwiftNIO 1.11 we shipped improved interfaces for Channels to support
asserting being in the event loop. This is necessary because Dispatch
provides no non-precondition way to 100% guarantee that you are on a
specific queue, which is a requirement for accurate behaviour of
inEventLoop.

Modifications:

- Added an implementation of preconditionInEventLoop.
- Changed all assertions to use new interface.
- Required NIO 1.11.

Result:

Accurate assertions
2018-11-06 17:44:41 +00:00
Jim Dovey 9e8685be61 Fixes #8, and cleans some switch cases. (#9)
Motivation:

One bugfix, some cleanliness.

Modifications:

`NIOTSListenerChannel.doClose0()` now evaluates and updates `self.bindPromise` irrespective of whether `self.nwListener` had been set.

Also, some case statements could be better: I've swapped `case _ as Thing:` with `case is Thing:`, and I've inlined the `let` value from `case _ as Thing: let thing = x as! Thing` to simply be `case let x as Thing:`.

Result:

If the call to create the `NWListener` in `NIOTSListenerChannel.beginActivating0()` throws an error, any promise passed to that method will now correctly be updated, where before it would be silently ignored, potentially causing a waiting caller to wait forever.

Also, no case statements remain that might cause damage to my tooth enamel.
2018-10-16 10:29:47 +01:00
Jim Dovey e14a834008 Some cleanliness changes. (#7)
* Use DispatchWorkItem.cancel() for cancellation. Make StateManagedChannel.beginActivating() use the same methodology as all the others.

* A needless `if let x = opt` that could be replaced with a question mark.
2018-10-01 05:55:53 +01:00
Johannes Weiss fb47fc1614 advertise CocoaPods over SwiftPM for NIOTS (#6)
Motivation:

Today, SwiftPM unfortunately doesn't offer a great story for macOS/iOS
App development. Therefore we should recommend the
SwiftNIO/SwiftNIOTransportServices Pods.

Modifications:

recommend CocoaPods in the readme

Result:

Hopefully less frustration.
2018-09-19 09:50:59 +01:00
Johannes Weiss fb2a2413b1 empty commit
for administrative purposes
2018-09-12 12:39:13 +01:00
Cory Benfield 94ef6a151c Add Cocoapods podspec generation. (#3)
Motivation:

A number of users have asked for the ability to install
NIOTransportServices via Cocoapods. This is an entirely reasonable
request, so let's do it.

Modifications:

Added a script that can generate, and optionally upload, a specfile
for NIOTransportServices.

Result:

Users can use cocoapods if they prefer.
2018-08-16 16:37:46 +01:00
Cory Benfield 897eb363f5 Handle errors during channel setup. (#2)
Motivation:

If an error is encountered early in the bootstrap process we should
probably not hit an assertion.

Modifications:

Added tests that we don't crash when closing idle channels.

Result:

Fewer crashes.
2018-08-08 19:15:33 +01:00
Cory Benfield 955d1b91e7
Add support for SO_REUSEADDR and SO_REUSEPORT. (#1)
Motivation:

These are commonly-set socket options for channels, and we should
support them when using Transport Services as well.

Modifications:

Pass the socket options through to allowLocalEndpointReuse.

Result:

SO_REUSEADDR and SO_REUSEPORT will be available.
2018-08-08 17:22:02 +01:00
Cory Benfield 6475881aea Initial commit 2018-07-18 17:11:24 +01:00