Commit Graph
813 Commits
Author SHA1 Message Date
Johannes Weiss ce2aaf1792 fix Posix.fcntl return type (#575)
Motivation:

Previously the code said that fcntl doesn't return anything but that's
just not true, it returns `CInt`.

Modifications:

Made `fcntl` return `CInt` and tested that.

Result:

more correct code and more tests
Motivation:

Explain here the context, and why you're making that change.
What is the problem you're trying to solve.

Modifications:

Describe the modifications you've done.

Result:

After your change, what will change.
2018-08-29 15:39:49 +01:00
Cory Benfield 658c3e75ca Make withUnsafeMutable{Readable,Writable}Bytes inlinable. (#558)
Motivation:

I spotted this while flamegraphing: apparently we missed the
declaration for inlineability here.

Modifications:

Made these two functions inlineable.

Result:

Better optimizations.
Motivation:

Explain here the context, and why you're making that change.
What is the problem you're trying to solve.

Modifications:

Describe the modifications you've done.

Result:

After your change, what will change.
2018-08-29 15:39:49 +01:00
Johannes Weiss efca71c0ab fix races in RepeatedTasks and its tests (#555)
Motivation:

There were a number of race conditions in both the RepeatedTasks
implementation and its tests:

- #554: the RepeatedTask could fire more than once before the
  cancellation was actually processed leading to a crash in tests
- #548: a test was testing that the RepeatedTask ran a certain
  number of times but the counting was racing with the checking
- TOCTOU issue: When a RepeatedTask was cancelled it was possible that
  it fires one extra time because a TOCTOU issue

Modifications:

- fixed the test races
- fixed the TOCTOU issue by checking if it was cancelled when it's
  executed rather than only when it's scheduled to be executed

Result:

- tests should be more stable (fixes #548 & fixes #554)
- RepeatedTask cancellation improved
Motivation:

Explain here the context, and why you're making that change.
What is the problem you're trying to solve.

Modifications:

Describe the modifications you've done.

Result:

After your change, what will change.
2018-08-29 15:39:49 +01:00
Johannes Weiss 2e2308dcfd tests hygiene: a lot fewer naked trys (#552)
Motivation:

Naked `try`s in tests are a problem because if they're hit you'll get a
bad error message and likely no file/line information. That has made
many flaky tests harder to debug than necessary.

Modifications:

- fix a lot of naked `try`s
- symlink `TestUtils` from `NIOTests` into `NIOHTTP1Tests`
- make a bunch of `wait()`s synchronous that were asynchronous by
  accident

Result:

- better code
- easier to debug test failures
- setting better example
Motivation:

Explain here the context, and why you're making that change.
What is the problem you're trying to solve.

Modifications:

Describe the modifications you've done.

Result:

After your change, what will change.
2018-08-29 15:39:49 +01:00
Cory Benfield 2f276312af Make bad websocket parser states unrepresentable. (#547)
Motivation:

Apparently when I wrote the WebSocket parser I forgot that enums are
great, and so I added a bunch of optional properties. That was silly.
This patch changes the WSParser structure to use an enum with
associated data to ensure that we only store state when we are supposed
to, and to guarantee that the state is good.

Modifications:

Move all state to enum case associated data.

Result:

Easier to validate the correctness of the WSParser code.
Motivation:

Explain here the context, and why you're making that change.
What is the problem you're trying to solve.

Modifications:

Describe the modifications you've done.

Result:

After your change, what will change.
2018-08-29 15:39:49 +01:00
Johannes Weiss 69744b4898 switch Socket API to Unsafe(Mutable)RawBufferPointers (#540)
Motivation:

The (`internal`) `Socket` API should've always been based on
`Unsafe(Mutable)RawBufferPointer`s but for some reason (probably just
age) it was `Unsafe(Mutable)Pointer<UInt8>` alongside a `size: Int`.

Modifications:

switched the `Socket` APIs from `Unsafe(Mutable)Pointer<UInt8>` and a
size to `Unsafe(Mutable)RawBufferPointer`.

Result:

better Swift code.
Motivation:

Explain here the context, and why you're making that change.
What is the problem you're trying to solve.

Modifications:

Describe the modifications you've done.

Result:

After your change, what will change.
2018-08-29 15:39:49 +01:00
Ole Begemann e960858bf6 Simplify C string to String conversion in IOError.reasonForError (#544)
* Simplify C string to String conversion in IOError.reasonForError

Motivation:

The standard library already has a String initializer that takes a
null-terminated UTF-8 C string. There's no need to construct an
UnsafeBufferPointer to use the Collection-based init(decoding:as:).

Modifications:

Replaced a manual pointer conversion with the appropriate stdlib API.

Result:

No change. Both version return the same String. The new version is
is arguably more correct because it saves the memory-rebinding step.

I haven't added new tests because the modified code is covered by
SystemTest.testErrorsWorkCorrectly.

Motivation:

Explain here the context, and why you're making that change.
What is the problem you're trying to solve.

Modifications:

Describe the modifications you've done.

Result:

After your change, what will change.
2018-08-29 15:39:49 +01:00
Cory Benfield cf08e673dc Avoid implicit conversion. (#566)
Motivation:

We were inadvertently doing an implicit integer conversion from
ssize_t to unsigned int in our sendmmsg shim. This can sometimes
generate warnings. The conversion itself is safe.

Modifications:

Make the conversion explicit.

Result:

No warnings.

(cherry picked from commit 131f378d95)
2018-08-10 13:25:10 +01:00
Cory Benfield 3940592a6c Remove unnecessary import in c-atomics.h (#561)
(cherry picked from commit db88f35d49)
2018-08-10 12:30:53 +01:00
Ole Begemann c6acf77fc9 Fix some typos in comments (#543)
Motivation:

I came across a few typos and then went through the entire code base
fixing similar errors when I noticed a pattern.

Modifications:

No changes to the code, just to comments.

Result:

No changes.
2018-08-01 15:57:27 +01:00
Ole Begemann 81307bd24f Fix Unmanaged.fromOpaque() usage in class Thread (#542)
Motivation:

As discussed with Andrew Trick on the Swift Forums, the additional call
to assumingMemoryBound(to:) is redundant here. Unmanaged.fromOpaque
takes a raw pointer, and p is just that.

See https://forums.swift.org/t/withunsafetypepunnedpointer/14540/9
for the discussion.

Modifications:

Deleted an unnecessary call to assumingMemoryBound(to:). With this
change, we follow the intended usage of Unmanaged more closely.

Result:

No material change. We save one redundant UnsafeRawPointer ->
UnsafePointer<ThreadBox> -> UnsafeRawPointer conversion.
2018-08-01 15:29:13 +01:00
Cory Benfield beadc98c1a Deprecate and replace changeCapacity. (#539)
Motivation:

As described in #537, ByteBuffer.changeCapacity is not a very good
function. We want to replace it with a better one, more similar to
reserveCapacity on the standard library data structures, and ideally
substantially faster.

Modifications:

- Deprecated ByteBuffer.changeCapacity.
- Added ByteBuffer.reserveCapacity.
- Changed the implementation of changeCapacity to call reserveCapacity
  when we're increasing the capacity.

Result:

Better APIs, better performance in the legacy ones, everything is
better.
2018-08-01 14:47:56 +01:00
Franz Busch 82f0f99570 Iterating over the EventLoops from EventLoopGroups (#509)
* EventLoopIterator

Provide a way to iterate over the EventLoops that compose an EventLoopGroup

Motivation:
For some use cases, it might be necessary to access the underlying event loops. See #497.

Modifications:
Added an EventLoopIterator as well as a new protocol requirement to EventLoopGroup called makeIterator() -> EventLoopIterator? . This is optional to avoid a SemVer Major, but will be made non-optional with 2.0.0. A current implementation is provided for every EventLoop through a protocol extension as well as for the MultiThreadedEventLoopGroup.

Result:
It is now possible to iterate over the EventLoops that compose a EventLoopGroup
2018-07-31 13:59:31 +01:00
Max Desiatov 0bc206feaf Added write function to NonBlockingFileIO (#531)
Motivation:

`NonBlockingFileIO` currently provides multiple read functions, but no functions to write to a `FileHandle` in an asynchronous non-blocking way.

Modifications:

`NonBlockingFileIO` struct now has simple basic `write` function that supports writing from a `ByteBuffer` to a `FileHandle`. Added `testWriting()` to `NonBlockingFileIOTest`.

Result:

`NonBlockingFileIO` now has a basic building block for asynchronous non-blocking writes.

Resolves #406.
2018-07-31 13:31:46 +01:00
Johannes Weiss 3913771129 improve documentation for ByteBuffer.get* methods (#535)
Motivation:

`ByteBuffer`'s `get*` methods can be used in an unsafe way and we didn't
warn the user enough.

Modifications:

Warn the user in the documentation of all the `get*` methods.

Result:

Less confusion.
2018-07-31 12:03:57 +01:00
Cory Benfield 3803d9b096 More featureful error handling options for WebSockets (#528)
Motivation:

Currently if you hit a parse error in the WebSocketFrameDecoder, that
handler takes it upon itself to return the error code and shut the connection
down. That's not really its job: it's not a pattern that we use anywhere
else, and it prevents users from overriding this handling with their own
choices.

We should stop doing that. Unfortunately, we can't totally stop it because
it's a supported feature in the current release of NIO, but we can give
users the option to opt-out, and also build our future solution at the same
time.

Modifications:

1. Added support for disabling the automatic error handling in
    WebSocketFrameDecoder.
2. Created a new WebSocketProtocolErrorHandler class that will be used for
    default error handling in 2.0.
3. Added support to the WebSocketUpgrader to disable automatic error handling
    altogether.
4. Changed the WebSocketUpgrader to use the WebSocketProtocolErrorHandler
    for default error handling when necessary.

Result:

Better separation of concerns, and users can override NIO's default
error handling behaviour.
2018-07-31 10:27:12 +01:00
Daniel Dunbar d31f4a249a [EventLoopFuture] Ensure client #file/#line are forwarded in mapIfError. (#533)
Motivation:

This ensures that the client's context information will be propagated into
the promise which is implicitly created by thenIfError(). Without this, if
that promise leaked the client would only see information about where it was
allocated inside of NIO, which is not helpful.

Modifications:

Propagate #file/#line.

Result:

Client's will see a #file/#line in their code, rather than something like:

```
Fatal error: leaking promise created at (file: ".../.build/checkouts/swift-nio.git-bla/Sources/NIO/EventLoopFuture.swift", line: 583)
```
2018-07-31 08:42:27 +01:00
Cory Benfield f55fc64535 Avoid hot-looping when autoRead is disabled. (#526)
Motivation:

On macOS it is possible to hot-loop on kevent when a channel has autoRead
disabled but pending data in the receive buffer. This is because
EVFILT_EXCEPT will fire when there is pending data in the receive buffer.

For now we work around this by setting NOTE_LOWAT to Int.max, which will
ensure that we don't actually get EVFILT_EXCEPT fired for pending data.

Modifications:

- When registering EVFILT_EXCEPT, set NOTE_LOWAT to Int.max.
- Fix a test that definitely didn't test what it wanted to.

Result:

No hot-loops with pending data.
2018-07-26 11:48:05 +01:00
Johannes Weiss 8c5eee85fc remove unnecessary UInt8 pointer binds (#524)
Motivation:

The bytes that a Unsafe(Mutable)RawBufferPointers points to can be
accessed directly as `UInt8`s. We didn't know that so we bind
`ByteBuffer`s memory to `UInt8` so that we can access it as
`UnsafePointer<UInt8>` using `assumingMemoryBound(to: UInt8.self)` in
many places. Most of the time that is unnecessarily awkward and
unnecessary.

Modifications:

- remove some easy instances where we access an
  `UnsafeMutableBufferPointer` as `UnsafeBufferPointer<UInt8>` just to
  read some `UInt8`s.

Result:

less awkward looking code
2018-07-23 19:11:19 +01:00
John Connolly e56d1cc41c Optional promotion bug (#521)
Motivation:

Fix comparison that causes incorrect processing of nonexistent events via optional promotion.

Modifications:

Changed comparison to use _none

Result:

No processing nonexistent events.
2018-07-18 16:20:21 +01:00
Franz Busch ae13d135f7 Pass RepeatedTask to its task closure (#515)
Pass the reference to RepeatedTask to its closure to allow a thread-safe cancelling.

Motivation:

With the current implementation, one has to create a reference and use a lock to thread-safely cancel the RepeatedTask. This makes the use more difficult and error-prone.

Modifications:

Added a RepeatedTask parameter to the scheduleRepeatedTask closure.

Result:

It is now possible to cancel the RepeatedTask from within the task closure.
2018-07-17 16:07:55 +01:00
Nethra Ravindran 6a90e6a682 Use case-insensitive protocol names for indexing the upgraders dictionary (#520)
Motivation:

We should not treat the HTTP protocol upgrade string as a case-sensitive
string, as clients may incorrectly deviate from the string as specified,
and we should still tolerate that.

Modifications:

Treat the upgrade string as case insensitive.

Result:

Wider compatibility for HTTP upgrade.
2018-07-17 08:47:57 +01:00
Cory Benfield 799060071a Cleanup wrapErrorIsNullReturnCall. (#511)
Motivation:

Given that wrapErrorIsNullReturnCall exists purely to wrap syscalls that
return NULL pointers on errors, there is no point allowing the return
value to be nil. Additionally, it's currently weirdly specific about the
return pointer type, so we can make the function generic.

Modifications:

- Make the return value of wrapErrorIsNullReturnCall generic.
- Make the return value of wrapErrorIsNullReturnCall non-optional.

Result:

Easier to use wrapErrorIsNullReturnCall and any matching function
2018-07-12 12:21:19 +01:00
Johannes Weiss 072babe443 ByteBuffer: deal correctly with underreporting ContiguousCollections (#501)
Motivation:

ContiguousCollections shouldn't give access to more than `count` bytes
via `withUnsafeBytes` but if they do we should still handle this
correctly and only copy `count` bytes.

Modifications:

- copy an upper limit of `count` bytes
- fail hard if `withUnsafeBytes` offers fewer bytes as we can't do
  anything sensible then.

Result:

even illegal `ContiguousCollection` implementations don't cause issues.
2018-07-12 11:56:40 +01:00
Esteban Torres e9aa6926ef Make CircularBuffer conform to more protocols [Fixes #350] (#466)
Motivation:

During the `PR` apple/swift-nio#347 there was a discussion around which
protocols this autoexpanding buffer should conform; the following 3
being the winners:

1. BidirectionalCollection
2. RandomAccessCollection
3. RangeReplaceableCollection

Modifications:

Added conformance to the 3 protocolos and provided implementaiton for 4
methods:

1. replaceSubrange(:with:)
2. index(before:)
3. removeSubrange(:)
4. remove(at:)
5. removeLast(:)

Result:

With the conformance of this 3 protocols and the implementation of this
5 functions we get dropLast(), dropLast(:), removeFirst(), removeLast()
& popLast() for free.
2018-07-12 07:58:42 +01:00
Franz Busch c2c008e53f Repeated Scheduling (#488)
Provide a mechanism to repeatedly schedule a task in the EventLoop

Motivation:
In some cases a certain task should run repeatedly, like polling an API or querying a database. For these scenarios a repeated scheduling mechanism is beneficial.

Modifications:
Added a method to EventLoop to schedule repeated tasks. 

Result:
It is possible to schedule task with an initial delay and a fixed delay now. Furthermore, these task can be cancelled.
2018-07-10 14:59:35 +01:00
Johannes Weiss ee0c74e9e2 document EmbeddedChannel (#464)
Motivation:

We had no EmbeddedChannel documentation.

Modifications:

Add EmbeddedChannel documentation.

Result:

Less lacking documentation.
2018-07-05 19:18:00 +01:00
Johannes Weiss 6848e7b8d7 ByteBufferAllocator: switch to size_t where appropriate (#503)
Motivation:

In a few situations we used `Int` in places where malloc/realloc
actually use `size_t`. On 64-bit platforms this doesn't actually matter
but on 32-bit it does!

Modifications:

- replace `Int` with `size_t` where appropriate

Result:

- should be able to use more than 2GB on 32-bit platforms
2018-07-05 09:00:42 +01:00
Lev Walkin 5347ab3e9f use a standard way to determine processor count (#496) 2018-07-03 11:45:19 +01:00
Johannes Weiss 89d46464ec workaround for Swift 4.2 compatibility issue with 4.0 (#494)
Motivation:

In Swift 4.2 you'll get a warning if you use an internal typealias from an
`@inlinable`/`@_inlineable` function. To fix it, you usually make it
`@usableFromInline`/`@_versioned`. Swift
4.0 however doesn't support those attributes for typealiases. The workaround is
to just make the typealias public (and underscored).

Modifications:

make `ByteBuffer.Capacity` and `ByteBuffer.Index` underscored and public

Result:

compiles warning-free on Swift 4.0, 4.1 and 4.2
2018-06-26 16:29:33 +01:00
Esteban Torres 29d6bf029a Nil NIOHTTP1Server dynamic handlers (#468)
Motivation:

The server attaches a dynamic handler to requests and will keep passing
data until the handlers are removed; which never happens.

Modifications:

`nil` out the `handler` when `completeResponse` is called.

Result:

When connections are reused we now get the correct dynamic handler for
it instead of the previous one.
2018-06-12 10:23:51 -07:00
Norman Maurer a67e85677a Allow to create ByteBufferView of all bytes in a ByteBuffer (#485)
Motivation:

We used an incorrect precondition and so it would be hit if someone tried to create a ByteBufferView add all bytes in a ByteBuffer.

Modifications:

Allow upperBound up to capacity

Result:

Fixes https://github.com/apple/swift-nio/issues/482.
2018-06-12 08:12:27 -07:00
Johannes Weiss 8fd397b3d4 fix ASCII art in ChannelPipeline docs (#462)
Motivation:

The ASCII art in the ChannelPipeline docs was slightly broken, this
fixes it.

Modifications:

fix ASCII art

Result:

less broken ASCII art
2018-06-09 19:41:01 -07:00
Cory Benfield e6787d3714 Update http_parser (#471)
Motivation:

Our copy of http_parser has become almost a year old now, and there are
both some bugfixes that improve correctness and some performance
improvements in http_parser that we should pick up.

Modifications:

- Updated http_parser
- Added tests to confirm we don't suffer from
    https://github.com/nodejs/http-parser/pull/432
- Added tests that we didn't get broken by SOURCE verb addition.

Result:

Shiny new http_parser!
2018-06-09 18:18:24 -07:00
OleG 58c983c049 Fix receiving message from websocket client (#472)
Motivation:

The http handler was not removed after the websocket upgrade and so a crash could happen as the handler assumes it received HTTP data.


Modification:

Remove httpHandler from pipeline

Result:

Fix receiving message from websocket client
2018-06-06 09:57:13 -07:00
Johannes Weiss d78ae0beed improve BlockingIOThreadPool docs (#461)
Motivation:

The BlockingIOThreadPool were very sparse which is improved here.

Modifications:

The existing docs didn't really help much if you didn't already know why
you'd need an extra thread pool for blocking work.

Result:

docs more clear on when to use BlockingIOThreadPool
2018-06-03 10:58:27 +01:00
Johannes Weiss 3c35c076da add scheme to URLs in NonBlockingFileIO docs (#460)
Motivation:

In the NonBlockingFileIO, the docs contain links but the scheme was
missing so the links didn't work.
Note: Both URLs don't work with https:// so I had to use http://,
sorry...

Modifications:

added a scheme to the URLs so they actually work

Result:

dead links in NonBlockingFileIO fixed
2018-06-03 10:32:13 +01:00
Cory Benfield 695afc5205 Widen assertion on readEOF. (#453)
Motivation:

In Darwin it is possible for readEOF to be received before writable,
if we race connection teardown with registering for writable. See
https://github.com/apple/swift-nio/issues/452 for a more in-depth
explanation.

Modifications:

Widened the assertion.

Result:

People's code won't go bang.
2018-05-30 14:35:10 +01:00
Johannes Weiss 402883a603 introduce ByteBufferView (#411)
Motivation:

Sometimes it would be handy to have ByteBuffers conform to a
`Collection` where `Element == UInt8`. ByteBuffer however has multiple
modes how to operate so it would be wrong to have say the readable bytes
be the ByteBuffer's collection.
Therefore it would be nice to have a view into a `ByteBuffer` which is a
`Collection where Element == UInt8`. This introduces these.

Modifications:

- add `ByteBufferView`
- add `ByteBuffer.readableBytesView`
- add `ByteBuffer.viewBytes(range: ...)`

Result:

- easier to work with `ByteBuffer`s in the Swift ecosystem.
2018-05-30 14:10:20 +01:00
Johannes Weiss eb15a4950b ByteBuffer: simplify ensureAvailableCapacity (#454)
Motivation:

ByteBuffer._ensureAvailableCapacity is quite complicated and the code
can be simplified by re-using existing code.

Modifications:

reuse more existing code

Result:

ByteBuffer code easier to understand
2018-05-30 12:52:34 +01:00
Johannes Weiss 25c6cd5982 make _UInt24 and _UInt56 printable (#445)
Motivation:

_UInt24 and _UInt56 didn't have a CustomStringConvertible conformance
which this patch is adding.

Modifications:

add CustomStringConvertible instances.

Result:

easier to debug stuff
2018-05-29 08:04:45 +01:00
Norman Maurer 82a6e4d821 Rename numThreads to numberOfThreads parameter. (#443)
Motivation:

We should be consistent with naming and also choose descriptive names.

Modifications:

- Deprecate old init method that uses numThreads
- Add new init with numberOfThreads param name
- Everywhere use the new init

Result:

More consistent and descriptive naming. Fixes https://github.com/apple/swift-nio/issues/432.
2018-05-25 17:37:55 +02:00
Andrew Edwards bc6618e300 Updated the code comment to explain the correct type of Future result.
Motivation:

This is done because when using Xcode and option + Click on a function you get a help overview inline to see more information and the messaging was incorrect. This helps developers in the future who want to rely on docs via Xcode.

Modification:

Correct the docs

Result:

More correct docs.
2018-05-24 21:02:32 +02:00
Norman Maurer c566b64455 Change initializer to public for HTTPRequestDecoder (#438)
Motivation:

d53ee6dafc introduced a new constructor to HTTPRequestDecoder which allows to change the behaviour of handling left over bytes when an upgrade was detected and the decoder was removed. This was done as an internal init block as we wanted to to do as part of a patch release.

Modifications:

Change internal to public init

Result:

More flexible configuration possible.
2018-05-24 14:08:32 +01:00
Cory Benfield 77dc77b9b5 Don't provide promises when we don't care about results. (#437)
Motivation:

When we don't care about the result of an operation, we shouldn't provide
a promise.

While I'm here I also removed an unnecessary close() call in the
AcceptHandler: the close() would be called again almost immediately.

Modifications:

Removed a close() call.
Set `promise: nil` on a pair of close() calls.

Result:

Fewer promise allocations.
2018-05-24 12:53:51 +01:00
Norman Maurer d53ee6dafc Only forward bytes on removal when we know we can handle it (#430)
Motivation:

398b950eee introduced a change which forwarded bytes that were buffered in HTTPDecoder after it was removed when an upgrade was detected. This may be risky if we dont know that the pipeline can handle it.

Modifications:

- Add new initializer that allow us to configure if we should forward bytes or not.
- Automatically use this if we know that we added an upgrader
- Add unit tests.

Result:

Less risky implementation.
2018-05-23 20:26:24 +02:00
Cory Benfield 9e0eb8347a Correctly account for writes of all datagrams. (#431)
Motivation:

The Darwin gathering datagram writes shim incorrectly placed the
"bytes written" amount into the first slot in the array for every write.
This had the effect of incorrectly accounting for the amount of bytes
written for literally every element of a vector write. Not good.

Modifications:

Correctly account for each vector write element.

Result:

Lower risk of preconditions in incorrect situations, better accounting
of written bytes.
2018-05-23 17:48:10 +01:00
Norman Maurer 398b950eee Ensure HTTPDecoder will not run into re-entrance issues and correctly forward bytes left after removal. (#427)
Motivation:

We need to ensure we correctly guard against re-entrancy for all cases. Also we did not correctly ensure we forward pending data after removal which could lead to missing data after upgrades.

Modifications:

- pause the parser when we need to callout to the pipeline and so ensure we never fire events throught the pipeline while in callbacks of http_parser
- correctly forward any pending bytes if an upgrade happened when the decoder is removed
- Ensure HTTPUpgradeHandler only remove decoder after the full request is received
- Add testcase provided by @weissi

Result:

Correctly handle upgrades and pending data. Fixes https://github.com/apple/swift-nio/issues/422.
2018-05-23 12:38:53 +01:00
Johannes Weiß 80363d9d8c fix EventLoops that Bootstrap channel initialiser's call out on (#424)
Motivation:

Previously we were not running the (child/server)channelInitializers on the
event loop associated to the `Channel` we're initialising. Almost all
operations in there are pipeline modifications which are thread safe so
it presumably wasn't a massive correctness issue. However it's very
expensive to hop threads that often and it is also very unexpected. This
addresses this issue.

Modifications:

made all (child/server)channelInitializers run on the event loop that is
associated to their `Channel`

Result:

- more correctness
- less unexpected behaviour
2018-05-22 15:58:43 +01:00
Johannes Weiss ec880b0853 don't just drop Channels on the floor if registration fails
Motivation:

If registration of a Channel fails we need to close that Channel.
Previously we'd just drop it on the floor which triggers an assertion
that an open channel got leaked.

Modifications:

In cases where the Channel registration fails, we need to close that
channel.

Result:

- No crashes if registration fails.
- fixes #417
2018-05-22 11:29:20 +01:00