Commit Graph
22 Commits
Author SHA1 Message Date
Saleem Abdulrasool 5270fa81df IO: extend IOError for Windows (#1460)
There are three different error domains that we deal with in NIO, which
need to be differentiated.  Store the error with the domain to ensure
that we can identify the error domain.
2020-03-23 16:29:14 +00:00
Doug Friedman a4fe7d4840 get IOError down to git in an existential container (#1355) (#1376)
resolves #1355 shaving off some bytes from IOError struct

Motivation:

It's important for frequently used errors to fit in existential containers because otherwise throwing them leads to allocations.

Modifications:

- Don't store `StaticString`s anymore which are 2 words + 1 bytes wide

Result:

Fewer allocations when IOErrors are thrown.
2020-02-03 12:30:37 +00:00
George Barnett 6050c9c864 Fix documenation markup (#799)
Motivation:

Quick Documentation was not rendering some parameter documentation
correctly as it was over-indented.

Modifications:

Reduced indentation for over-indented parameters.

Result:

Quick Documentation renders correctly.
2019-02-01 15:34:59 +00:00
Johannes Weiss 95b290a51f use automatic Equatable conformances (#737)
Motivation:

No code is the best code, let's have the compiler generate more
Equatable instances for us.

Modifications:

remove some hand-written Equatable conformances

Result:

less code, possibly fewer bugs
2019-01-07 11:52:22 +00:00
Johannes Weiss e415d654a5 internalise things made public by accident (#463)
Motivation:

A few things are public by accident, this makes those internal for NIO
2.0.0.

Modifications:

internalise a few things

Result:

less public API
2018-12-17 19:19:40 +00: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
Johannes Weiß a1ab3f32b3 propagate socket errors on .reset (#325)
Motivation:

Since #286, we do eagerly detect connection resets which is good. To
resolve the situation we first try to read everything off the socket. If
something fails there, everything is good and the client gets the
correct error. If that however doesn't lead to any errors, we would
close the connection with `error: ChannelError.eof` which the client
would then see for example on a connect that happened to get
`ECONNRESET` or `ECONNREFUSED`. That's not right so these situations are
fixed here.

Modifications:

- on reset, try to get the socket error if any
- if no socket error was detected, we send a `ECONNRESET` because we
  know we have been reset but not why and didn't encounter any errors
- write tests for these situations

Result:

connection resets that don't hit any other errors will now see the
correct error
2018-04-18 18:56:00 +01:00
Bas Broek b180113d81 Improve switch readability
Motivation:
This changes two things:
- it removes the negation of non-used associated types (the removal of `(_)`).
- it prefers exhausting `switch`es over `default`ing.

This change does not impact bahavior; it is pure refactoring.

Modifications:

Omitting needless `(_)`'s and explicitly exhausting switches.

Result:

This change is pure refactoring.
2018-03-19 14:43:38 +01:00
adamnemecek 0bbed6d72f * removed trailing whitespace (#52) 2018-03-02 15:40:52 +09:00
Norman Maurer 55e99b603d Expose BlockingIOThreadPool
* Expose BlockingIOThreadPool

Motivation:

Sometimes we need to execute some blocking IO. For this we should expose the BlockingIOThreadPool that can be used.

Modifications:

- Factor out BlockingIOThreadPool
- Added tests
- Correctly start threadpool before execute NonBlockingIO tests.

Result:

Possible to do blocking IO.

* Corrys comment

* Correctly start pool before using it
2018-02-16 14:53:19 +01:00
Johannes Weiss 07ff34087a make IOResult equatable 2018-01-31 18:02:32 +00:00
Johannes Weiß 8c7105f0a3 remove lazy create todo 2018-01-31 10:58:09 +00:00
Johannes Weiß c79c5ba364 re-export Darwin/Glibc and reduce number of #if os(...) 2018-01-09 15:08:17 +00:00
Johannes Weiss 215620d7a6 syscall wrapper: don't do an allocation for every failed syscall 2017-12-07 15:37:12 +00:00
Norman Maurer 5475ba069a Add docs for IO and Selectable and also rename error parameter name to errorCode to ensure we not capture errno by mistake.
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.
2017-12-05 15:44:50 +01:00
Johannes Weiss 98017432b8 dont require Foundation for IOError description creation 2017-12-01 14:31:37 +00:00
Norman Maurer 68a475b37a Rename IOError.errno to IOError.errnoCode as errno is always in scope 2017-11-17 15:45:12 +01:00
Norman Maurer ba35fcb5a5 Move all syscalls that also need to handle errno in an extra file and ensure we not get any problems with invalid errno handling
* Move all syscalls that also need to handle errno in an extra file and ensure we not get any problems with invalid errno handling

Motivation:

Because it is possible ARC cause an syscall and so set the errno value we need to ensure no ARC can ever happen before we were able to read the errno value that was caused by an syscall we made.

Modifications:

Move all syscalls to an extra file (System.swift) and ensure all exposed methods are marked with `@inline(never)` and not capture any classes. This ensures no ARC can ever happen.

Result:

Be able to safely read errno if needed.

* Comments
2017-11-16 16:41:19 +01:00
Norman Maurer 1619c3d7c8 Add support for sendFile by allow to write a FileRegion. 2017-08-11 20:32:04 +02:00
Norman Maurer c601d7683b We not depend on the errno module anymore 2017-07-03 19:50:32 +02:00
Norman Maurer fd936557c4 Move Socket/* into NIO/ for max performance
Before:

`Bandwidth per channel: 18870.319⇅ Mbps (2358789.8 kBps)`

After:

`Bandwidth per channel: 21330.617⇅ Mbps (2666327.1 kBps)`
2017-07-03 14:52:09 +02:00