Commit Graph
1096 Commits
Author SHA1 Message Date
Albert Aleksieiev a59293cbcd add Android support (#609)
### Motivation:

make swift-nio compatible with Android, and pass all test in Android.

### Modifications:

* add missed `ifaddrs` implementation
* add missed thread related functions - `CNIOLinux_pthread_getname_np`, `CNIOLinux_pthread_setaffinity_np` and `CNIOLinux_pthread_getaffinity_np`
* fix types incositency between Linux and Android, e.g. `Epoll.swift` class
* make bytes counter explicitely 64bits to avoid overflow on 32bit, in `PendingWritesManager.swift` and `PendingDatagramWritesState.swift`
* fix issue with Unix domain socket, first byte need to be zero in Android
* several incosistency fixes between Linux and Android api.

### Result:

now swift-nio works on Android. All tests passed!
2018-09-27 11:32:43 +01:00
Cory Benfield c73eb57694 Support UDP multicast. (#618)
Motivation:

A large number of very useful protocols are implemented using multicast
with UDP. As a result, it would be helpful to add support for joining and
leaving IP multicast groups using SwiftNIO.

Modifications:

- Defines a MulticastChannel protocol for channels that support joining and
  leaving multicast groups.
- Adds an implementation of MulticastChannel to DatagramChannel.
- Adds a interfaceIndex property to NIONetworkInterface.
- Adds if_nametoindex to the Posix enum.
- Adds a isMulticast computed property to SocketAddress
- Adds a demo multicast chat application.
- Add a number of multicast-related socket options to SocketOptionProvider.

Result:

NIO users will be able to write channels that handle multicast UDP.
2018-09-24 10:24:09 +01:00
Johannes Weiss 2e96e47016 explain some force tries/unwraps (#619)
Motivation:

It's generally good style to explain why something needs to be force
unwrapped/tried if not obvious.

Modifications:

Add explanations to a bunch of places.

Result:

Code easier to understand.
2018-09-19 15:51:03 +01:00
Cory Benfield be4ea8ac74 Add SocketOptionChannel for wider socket options. (#589)
Motivation:

A small number of socket options have values that do not fit into a C
int type. Our current ChannelOption based approach for setting these
simply does not work, and cannot be extended to support the truly arbitrary
types that the setsockopt/getsockopt functions allow here.

This makes it impossible to use some socket options, which is hardly a
good place to be.

There were a number of ways we could have addressed this: we could have
special-cased all socket options with non-integer types in ChannelOption,
but I believe that would be too manual, and risk limiting users that need
to set other socket options. We could also have added a ChannelOption
that simply allows users to pass a buffer to write into or read from,
but that is a very un-Swift-like API that feels pretty gross to hold.

Ultimately, the nicest seemed to be a new protocol users could check
for, and that would provide APIs that let users hold the correct concrete
type. As with setsockopt/getsockopt, while this API is typed it is
not type-safe: ultimately, the struct we have here is treated just as a
buffer by setsockopt/getsockopt. We do not attempt to prevent users from
shooting themselves in the foot here.

This PR does not include an example use case in any server, as I will
provide such an example in a subsequent multicast PR.

Modifications:

- Added a SocketOptionChannel protocol.
- Conformed BaseSocketChannel to SocketOptionChannel.
- Wrote some tests for this.

Result:

Users can set and get sockopts with data that is larger than a C int.
2018-09-18 13:40:38 +02:00
Norman Maurer a0c6cffc88 Correct propagate channelActive events to the next handler when using… (#615)
* Correct propagate channelActive events to the next handler when using IdleStateHandler.

Motivation:

We missed to propagate the channelActive event to the next handler in IdleStateHandler, which means handlers placed after it in the pipeline will never receive such an event.

Modifications:

- Correctly call ctx.fireChannelActive()
- Add unit test to assert we forward all inbound events.

Result:

Fixes https://github.com/apple/swift-nio/issues/614.
2018-09-13 09:09:15 +02:00
Johannes Weiss 463f8d95d2 EventLoopPromise didn't point out it has reference semantics (#612)
Motivation:

Sometimes people assume that all `struct`s have value semantics but
that's not true. We should still point that out.

Modifications:

point out that EventLoopPromise has reference semantics

Result:

clearer docs
2018-09-11 15:16:06 +01:00
Cory Benfield 19444825fa Actually report errors when hitting blacklisted errnos. (#610)
Motivation:

It's not all that useful to print the value of the pointer from sterror.
Instead we should aim to print the string. While we're here, let's avoid
repeating too much code.

Modifications:

- Centralised the handling of blacklisted errnos.
- Correctly printed the error string when a blacklisted errno is hit.
- Updated the output of the assertion to include the function failing.

Result:

Better diagnostics when blacklisted errnos are hit.
2018-09-10 10:58:50 +01:00
Norman Maurer bf8c642896 Include ipaddress in SocketAddress.description. (#601)
Motivation:

WE should include the ipaddress in the description of SocketAddress if any way used as there may be no host at all.

Modifications:

- Always include ipaddress if possible.
- Add unit tests.

Result:

More useful description of the SocketAddress
2018-08-30 20:46:08 +02:00
Johannes Weiss 501af860f5 allow two distinct ChannelOptions of one type (#597)
Motivation:

Quite embarrasingly, we previously would only store one `ChannelOption`
per `ChannelOption` type. Most channel option types are distinct and
that's probably why it took so long to find this issue. Thanks
@pushkarnk for reporting. Unfortunately though, the most important
`ChannelOption` is `.socket` which crucially also holds a level and a
name. That means if you set two `ChannelOptions.socket` options with
distinct name/level, one would still override the other.

Example:

    .serverChannelOption(ChannelOptions.socket(SocketOptionLevel(SOL_SOCKET), SO_REUSEPORT), value: 1)
    .serverChannelOption(ChannelOptions.socket(SocketOptionLevel(SOL_SOCKET), SO_REUSEADDR), value: 1)

would only actually set the latter.

Modifications:

- made all common `ChannelOption` types equatable (for 2.0 this will
  be a protocol requirement)
- deprecated non-Equatable `ChannelOption` types
- zero out buffer before calling getsockopt as Linux doesn't do that

Result:

you can now set two distinct `ChannelOptions` for one type
2018-08-29 15:24:58 +01:00
Johannes Weiss df764fedf0 don't crash when Channel goes inactive in read triggered by write error (#594)
Motivation:

Previously we asserted that a Channel cannot go inactive after calling
out for a read that was triggered by (draining the receive buffer after)
a write error.

This assertion was put in place to guard against `readComplete` events
sent on inactive channels. It did that job just fine but crashes aren't
great so we now conditionally fire the `readComplete` event if the
Channel stays active.

Modifications:

make the readComplete event firing conditional

Result:

fewer crashes, more happy faces
2018-08-27 11:49:58 +01:00
Johannes Weiss 8ecced9e24 warn that ChannelHandlers should be instantiated within initializer closures (#590)
Motivation:

For (stateful) ChannelHandlers it's very important that the
ChannelHandlers get instantiated _within_ the bootstrap's initializer
closures (and not before that).

Modifications:

Add warnings about the fact that they should be instantiated within the
closures.

Result:

- better docs
- more correct user code
2018-08-24 09:04:44 +02:00
Johannes Weiss 927034f7de mark more Collections as ContiguousCollections (#586)
Motivation:

All the mutable variants and also some slices of clearly contiguous
collections weren't marked as ContiguousCollections but they should be.

Modifications:

- made UnsafeMutable[Raw]BufferPointer a ContiguousCollection
- made Slice<UnsafeRawBufferPointer> a ContiguousCollection

Result:

faster code
2018-08-23 17:18:51 +01:00
Johannes Weiss aaf434022f fix limits on 32-bit systems to values that work (#580)
Motivation:

We should have different constants for 32-bit systems where necessary
for example all the maximums should be Int32.max and not UInt32.max
because UInt32.max doesn't fit into an Int on 32-bit platforms. But
where unnecessary 32-bit and 64-bit should share maximum values.

Modifications:

- removed some constraints that should be unnecessary
- skip tests that can't work on 32-bit systems

Result:

better and more consistent 32-bit runs
2018-08-23 10:38:47 +01:00
Johannes Weiss 7de224eaf3 better documentation for MultiThreadedEventLoopGroup (#582)
Motivation:

MultiThreadedEventLoopGroup's docs didn't make it clear that you leak
threads if not shut down.

Modifications:

Add clarification that you should shut down
MultiThreadedEventLoopGroups.

Result:

hopefully clearer documentation.
2018-08-21 11:43:42 +01:00
Helge Heß e8c04e0eca Make tests work on 32-bit (#486)
* 32-bit fix for tests: Replace 0xDEADBEEF w/ 0x1337BEEF

Motivation:

Make tests compile on Raspberry Pi.

Modifications:

- Change tests so that they compile on 32-bit machines,
like Raspi. Replaced 0xDEADBEEF which doesn't fit into
an Int32, w/ 0x1337BEEF.
- make ByteBuffer work better on 32-bit
- fix other wrong assertions and limits that are too big on 32bit

Also use TimeAmount.Value in one test.

Result:

Tests will compile on Raspi ...
2018-08-16 18:05:11 +01:00
Johannes Weiss 0ce3cf5b79 if an EventLoopFuture.wait() blows up, tell users where (#578)
Motivation:

If the deadlock detection in EventLoopFuture.wait() blows up we should
tell users the file/line where they called it from not where our
preconditon is.

Modifications:

- add a file/line parameter with default value obvs

Result:

better diagnostics
2018-08-16 16:42:26 +01:00
Johannes Weiss a9072729bb output a hint if we get a reset connection w/o error set (#573)
Motivation:

We have one case in the code where we expect a socket error to be set
when we hit a connection that got the `.reset` event. On Linux that's
expected and therefore we just map this to `ECONNRESET`.
On other platforms however that is unexpected. Now I just found an
[Envoy commit](https://github.com/envoyproxy/envoy/commit/62f8e51bdd2d72cbac739087dabd3f51bdfc5cbd#diff-3315c7b2    91f78a482ebd4cbfc0545362R345)
which suggests this might not work on FreeBSD. This should prompt our
users to let us know if we ever see this error on non-Linux systems.

Modifications:

Add a message that makes it clear this is unexpected and link our
ticket.

Result:

we should learn if this actually happens on macOS.
2018-08-16 15:13:02 +01:00
Johannes Weiss 4117f4efae better wait on EventLoop detection (#553)
Motivation:

It's important that in NIO programs you don't call
EventLoopFuture.wait() on an EventLoop. We previously had some detection
built in but we can do better.

Modifications:

Detect wait() called on any of MultiThreadedEventLoopGroup's EventLoops.

Result:

Quicker and more deterministic detection if wait() abuse.
2018-08-16 10:44:32 +01:00
Johannes Weiss d7b5bf6e15 make ByteBuffer._Storage.fullSlice a computed property (#560)
Motivation:

ByteBuffer._Storage.fullSlice can always be trivially computed, so it
should be.

Modifications:

make ByteBuffer._Storage.fullSlice computed

Result:

saved almost 56 bits per ByteBuffer
2018-08-16 09:50:48 +01:00
Johannes Weiss d32d5c6a50 add forgotten selfs (#574)
Motivation:

Swift code that doesn't use explicit `self.` is hard to read, even
harder to search for and quite bug prone. During my analysis I found
quite a number of them, this fixes the ones I came across.

Modifications:

Add a bunch of missing explicit `self.`s

Result:

code easier to read and less bug prone
2018-08-16 09:28:24 +01:00
Johannes Weiss b6473b3539 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
2018-08-14 15:01:34 +01:00
Johannes Weiss f8600df5dc safer UnsafeRawBufferPointer use (#559)
Motivation:

Unsafe(Mutable)RawBufferPointers have a few APIs that make our code
easier to reason about. In this PR I'm trying to introduce some of it.

Modifications:

Improved UnsafeRawBufferPointer usage

Result:

code easier to reason about which hopefully leads to fewer bugs. Also:
In many cases we now get free bounds checking in debug mode, yay :).
2018-08-09 11:53:45 +01:00
Cory Benfield 71c6e8b3c9 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.
2018-08-07 17:31:02 +01:00
Johannes Weiss 2fec7a9766 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
2018-08-07 07:59:18 +01:00
Johannes Weiss 9c58336b34 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
2018-08-06 13:19:23 +01:00
Johannes Weiss a8aaa263fe add missing @discardableResults in readWith* methods (#549)
Motivation:

ByteBuffer has a number of readWith* methods, some of them return the
`T` which was returned from the closure. This shouldn't be discardable.
Others however just return thr number of bytes read which should be
discardable.

Modifications:

made the readWith* functions that return the number of bytes read
@discardableResults

Result:

nicer user code
2018-08-03 09:05:19 +01:00
Johannes Weiss b0b8a15100 remove more memory binding assumptions (#541)
Motivation:

It's poor style to assume a certain piece of memory is bound to a
certain type across a whole program. That's because any piece of code
run in between might have rebound the memory and also it's hard to prove
that the binding assumption is actually correct. Therefore we should
restrain from using them.

Modifications:

remove more assumptions that memory is bound to a certain type.

Result:

better code
2018-08-02 12:14:01 +01:00
Johannes Weiss baf5c947fd 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.
2018-08-01 18:51:33 +01:00
Ole Begemann cf55bee323 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.
2018-08-01 17:22:35 +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
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
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
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