Cory Benfield
67bb71e44b
Add a pending datagram writes manager
...
This change adds support for doing datagram-style writes. It's not currently
hooked up to anything, but it will be sometime soon.
2018-02-14 15:32:31 +00:00
Johannes Weiss
eaa8ffaee4
remove redundant labels
...
Motivation:
Lots of our most important operations had redundant labels like
func write(data: NIOAny)
the `data: ` label doesn't add anything meaningful and therefore it
should be removed.
Modifications:
removed lots of redundant labels
Result:
less redundant labels
2018-02-13 11:13:30 +00:00
Johannes Weiß
dba0a5379c
fix longstanding typo in newSucceededFuture
...
Motivation:
We used to have a method `newSucceedFuture` which should be
`newSucceededFuture`
Modifications:
grammar
Result:
better grammar
2018-02-13 09:55:33 +00:00
Johannes Weiß
2c95f53e0f
fix master build
...
Motivation:
master didn't build
Modifications:
fixed it
Result:
works again
2018-02-12 18:51:26 +00:00
Johannes Weiß
85b45e6912
make function names for connect/bind/SocketAddress more Swift-like
2018-02-12 15:09:22 +00:00
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
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ß
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
b09c1598af
Fix testcase which was not correctly updated as part of 845d9ee8e95e8ba61e550a26b0a70d59ee98c97d
2018-02-12 08:39:38 +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
3f357a3c79
Minor cleanups for Swift 4.1
2018-02-08 11:40:45 +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
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
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
Johannes Weiss
755ea5aedc
non-blocking file IO
2018-02-07 17:25:45 +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
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
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
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
Max (Swift) Moiseev
973a96004d
Get rid of free functions
...
* Lift the EventLoopFuture.== into the type extension and add the Equatable conformance
* Get rid of the only public free function systemCoreCount
2018-01-30 10:41:44 -08:00
Johannes Weiss
eab7d314f3
make Channel non optional in ChannelHandlerContext
2018-01-30 12:03:51 +00:00
Johannes Weiss
af4dabb0fa
rename the Future's functor map function to map
2018-01-30 08:25:20 +00:00
Johannes Weiss
b3799b9403
take OpenSSL support out of tree
2018-01-26 09:50:38 +00:00
Cory Benfield
1fffa95ad1
Make ChannelCore writes use NIOAny
2018-01-25 12:12:02 +00:00
Johannes Weiss
4a2425f5b7
promise leak debugging
2018-01-24 08:21:35 +00:00
Cory Benfield
92634a68fb
Add utility for detecting core count.
2018-01-22 12:05:43 +00:00
Cory Benfield
34cc404142
Refactor internal storage model for SocketAddress
2018-01-22 12:07:40 +00:00
Cory Benfield
9908b391db
Prevent SniHandler wrongly calculating packet length.
2018-01-19 16:39:46 +00:00
Johannes Weiss
7d5109a673
no auto headers for GET
2018-01-19 15:46:52 +00:00
Johannes Weiss
24abe7fe19
merge (& fix) the inbound and outbound channel pipelines
2018-01-19 14:50:37 +00:00
Johannes Weiss
db28cf4452
don't pretend user events are typed & remove tryUnwrap for in/outbound data
2018-01-19 14:12:57 +00:00
Norman Maurer
4d8cf1ff22
Add support for closing only the output / input side of the Channel.
2017-12-28 13:40:31 +01:00
Cory Benfield
1535c2f5fc
Add IP string parsing
2018-01-18 18:07:50 +00:00
Norman Maurer
2e2a82b27e
Try to drain inbound data on write error.
...
Motivation:
To ensure we not leave any unread data on the socket we should try to read one last time (if autoread is enabled).
Modifications:
- Depending on if autoread is enabled or not we will try to read one more time
- Guard against re-entry of flushNow0()
- Correctly handle SIGPIPE in all cases
- Add testcase
Result:
Drain data from socket on write error if needed.
2017-12-27 08:10:53 +01:00
Johannes Weiss
8b74d21562
more robust tempfiles for SSL trust bundle
2018-01-10 17:19:02 +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
b9a982bfa1
improve robustness of SSL/TLS tests regarding errors thrown
...
previously on some errors we'd leak a promise without a good way to
debug. This should shed some light on that.
2018-01-09 14:27:32 +00:00
Cory Benfield
9fd4006c93
Add explicit time control to EmbeddedEventLoop
2018-01-08 17:59:18 +00:00
Johannes Weiss
64ef7728f9
finish renaming ByteBuffer getters to getType
2018-01-09 09:32:39 +00:00
Johannes Weiß
5f21764710
fix compiler warning & typo
2018-01-08 16:48:44 +00:00
Cory Benfield
8ee527ac52
Simplify running code
2018-01-08 16:39:54 +00:00
Johannes Weiss
9a5390495e
improve channel pipeline
...
We now use two (doubly) linked lists (inbound & outbound) for the
ChannelPipeline. Previously we used two singly linked lists and an
array. That would give us the worst of the two worlds: Linear time
modifications and complicated code.
2018-01-05 18:17:34 +00:00
Johannes Weiss
8674154403
remove pretty much all try!s from the tests
2018-01-05 16:22:38 +00:00
Johannes Weiss
d2b671da66
make HTTPServerClientTests more robust
2018-01-05 15:19:22 +00:00
Johannes Weiss
62b4acaedf
ByteBuffer.clear: Prevent copying bytes if allocation is necessary
2018-01-05 15:01:48 +00:00
Johannes Weiss
e217dea875
fix EmbeddedChannel: created more than one EmbeddedEventLoop
2018-01-04 18:08:07 +00:00
Johannes Weiss
03a299795f
make the test*Blast() tests not crash but fail if ChannelPipeline doesn't work
2018-01-04 15:53:07 +00:00
Norman Maurer
43303437d1
Declare option label as optional in ClientBootstrap
2017-12-21 22:04:42 +01:00
Norman Maurer
8b9a31536e
Allow to specify a connect timeout
2017-12-20 15:26:39 +01:00
Norman Maurer
8f1ad37edd
Use camel case for ChannelOption factory values and add docs
2017-12-20 14:18:07 +01:00
Johannes Weiss
dfd25bf576
refactor Channel initialisation & *Bootstrap docs
2017-12-13 15:42:54 +00:00
Johannes Weiß
d7d1d5dbf5
fixed a near miss (thanks Swift 4.1 compiler warning)
2017-12-18 15:57:31 +00:00
Johannes Weiß
94e1af5452
compile warning-free on Swift 4.1
2017-12-18 15:37:57 +00:00
Johannes Weiss
fa35c603a0
on Darwin, sendfile might write fully and return EWOULDBLOCK
2017-12-15 16:58:12 +00:00
Cory Benfield
0fa0224623
Configure this pipeline properly
2017-12-15 12:29:28 +00:00
Norman Maurer
76482816e6
Prefix all ByteBuffer methods with `get` if these allow access to unitialized memory.
2017-12-15 12:24:09 +01:00
Cory Benfield
3614d09a4b
Provide a nicer setup helper for HTTP connections
2017-12-13 15:38:40 +00:00
Cory Benfield
4154a3bcbc
Don't shut connections aggressively in tests
2017-12-15 10:41:46 +00:00
Cory Benfield
f3e72c13f3
Add HTTP streaming compressor
2017-12-15 09:50:12 +00:00
Cory Benfield
bcdef57481
Correctly track the writer index
2017-12-15 08:24:38 +00:00
Cory Benfield
be3d8d00f8
Correctly decode HTTP HEAD responses
2017-12-13 17:10:44 +00:00
Johannes Weiss
8a1297eff1
Channel docs
2017-12-13 16:07:14 +00:00
Johannes Weiss
e60ef7fdc8
trivial: fix unused result warning in tests
2017-12-13 11:50:16 +00:00
Cory Benfield
07f5eb95e2
Enforce promise ordering for zero length writes
2017-12-12 16:38:31 +00:00
Cory Benfield
9b9caa1d20
Don't explode on zero-length writes
2017-12-12 16:04:21 +00:00
Johannes Weiss
e4ef4c19f7
fix write spinning (should be max `writeSpinCount` writes)
2017-12-12 14:14:10 +00:00
Johannes Weiss
4e188e74b3
Channel tests: use canary value to make sure we don't write past buffer end for iovecs
2017-12-12 13:26:28 +00:00
Johannes Weiss
59566c6365
Channel writes: Tighter asserts & now 100% test coverage
2017-12-12 12:57:45 +00:00
Johannes Weiss
69c0cd463b
fix random typos
2017-12-12 11:37:07 +00:00
Cory Benfield
2373863f54
No fatal error on unexpected non-ciphertext data
2017-12-12 11:31:05 +00:00
Johannes Weiß
25f4e2ceff
PriorityQueue: make it work for partial orders
2017-12-12 11:13:33 +00:00
Cory Benfield
584fdb6507
ByteToMessageDecoder must propagate ChannelInactive
2017-12-12 10:49:12 +00:00
Johannes Weiss
b203c602a9
Channel writes: more bugs found & fixed
2017-12-12 08:05:57 +00:00
Johannes Weiss
40454741d1
more interesting PriorityQueue test
2017-12-11 14:34:49 +00:00
Cory Benfield
ba183774f6
Don't assert clean shutdown
2017-12-11 13:13:15 +00:00
Johannes Weiss
64a1c2feb8
Channel writes: unit tests & lots of fixes
2017-12-11 12:20:46 +00:00
Johannes Weiss
8a4a658bc7
fix large ByteBuffer allocations
2017-12-08 10:37:14 +00:00
Johannes Weiss
b579f80efd
in failAll we double accounted for outstanding ByteBuffers :(
2017-12-08 09:40:31 +00:00
Johannes Weiß
e1b30f0a3d
fix Channel writes
2017-12-05 17:08:42 +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
7379be49f5
Replace mktemp usage with mkstemp to silence warnings when running tests.
...
Before this was printed out.
NIOOpenSSLTests/SSLCertificateTest.swift:105: warning: the use of `mktemp' is dangerous, better use `mkstemp' or `mkdtemp'
2017-12-04 18:48:49 +01:00
Johannes Weiss
ff991da658
make the CircularBuffer implementation more straightforward & docs
2017-12-04 16:59:16 +00:00
Norman Maurer
1a9cd14118
More agressively try to increase the number of bytes we read from the Channel per read.
...
Motiviation:
We used to only allocate one buffer per read loop (by default we use multiple reads per loop) and record for the next loop iteration if we need to allocate a bigger buffer or not. This can lead to very slowely ramping up of number of bytes we read. We should better detect if we should allocate a new buffer because we used all the writable bytes to allow faster ramping up of numbre of bytes to read .
Modification:
- Change RecvByteBufferAllocator.record to return a Bool that wil lsignal if we used all the writable bytes of the last allocation and so may want to try to allocate a bigger buffer again
- Adjust tests.
Result:
Faster adjustment of the ByteBuffer capacity when reading data.
2017-12-04 15:43:13 +01:00
Johannes Weiss
5eca60e46b
make ByteBuffer tests slightly more interesting
2017-12-01 17:39:23 +00:00
Johannes Weiss
98017432b8
dont require Foundation for IOError description creation
2017-12-01 14:31:37 +00:00
Johannes Weiß
a22fc02c51
ByteBuffer: fix a UInt underflow
2017-11-30 16:57:26 +00:00
Johannes Weiss
8335b6c3a0
replace priority queue
2017-11-28 16:13:26 +00:00
Cory Benfield
2cfa8c2381
Remove use of URL and FileManager from NIOOpenSSL
2017-11-23 10:11:38 +00:00
Cory Benfield
99188f3a99
Don't lose close promises
2017-11-21 19:00:36 +00:00
Johannes Weiß
06f9b1d63b
merge ConcurrencyHelpers
2017-11-21 18:32:33 +00:00
Johannes Weiß
33fe401322
rename Future/Promise to EventLoopFuture/EventLoopPromise
2017-11-21 17:41:36 +00:00
Johannes Weiss
4a74aca592
integration test for syscall wrapper
2017-11-21 15:00:25 +00:00
Johannes Weiß
202e1c37d7
port integration tests for HTTP server
2017-10-10 19:41:01 +01:00
Cory Benfield
229c23a63b
Support X.509 hostname validation
2017-11-20 14:26:22 +00:00
Johannes Weiss
09b8925591
make ChannelHandlerCtx operations not crash if channel is already closed
2017-11-17 14:57:25 +00:00
Johannes Weiß
936e812b32
make system call wrapper fast & test it
2017-11-16 15:42:03 +00:00
Norman Maurer
f369a17d42
Fix warnings that are cased by using try for functions that not throw. Leftover from 4a315c9e9d12345e70b838cdfea54ddb0b191da8
2017-11-16 19:39:16 +01:00
Cory Benfield
1cb736e370
Catch bugs with sync shutdown
2017-11-10 17:28:52 +00:00
Cory Benfield
4cf0bbaaf4
Make our circular buffers collections
2017-11-16 12:56:29 +00:00
Johannes Weiß
31cd14eaad
fix inEventLoop race and makes TSan happy
2017-11-10 14:56:33 -08:00
Cory Benfield
8ff2d5bb92
OpenSSL ALPN support
2017-11-13 12:45:57 +00:00
Cory Benfield
8d2f13be68
Add parent property
2017-11-13 10:11:52 +00:00
Johannes Weiss
f6343496c3
add another test for a very large number of buffered writes
2017-11-11 00:10:23 -08:00
Cory Benfield
be81dbacff
Forbid oversized writev calls
2017-11-10 16:08:49 +00:00
Cory Benfield
13d80285c8
Don't write too much to writev
2017-11-10 15:45:41 +00:00
Johannes Weiß
40edb34d8f
introduce & test ByteBuffer.readString
2017-11-08 13:06:09 -08:00
Cory Benfield
e72569e329
Add client-side SNI support
2017-10-25 15:04:46 +01:00
Cory Benfield
8efedf33fa
Add ALPN handler
2017-11-01 16:14:11 +00:00
Norman Maurer
976f4752df
Add HTTPRequestEncoder / HTTPResponseDecoder implementation and tests
2017-11-02 13:50:46 +01:00
Johannes Weiss
c18db56fc2
make >= 0 checks for index/length a precondition
2017-11-09 02:49:11 -08:00
Max Moiseev
dccbbf0bb7
Remove unnecessary Numeric constraint
2017-11-08 14:46:10 -08:00
Johannes Weiß
20800ed454
use the now fully featured FixedWidthInteger instead of EndiannessInteger
2017-11-08 13:08:02 -08:00
Cory Benfield
4d09289f9b
Add missing test
2017-11-08 14:33:57 +00:00
Norman Maurer
9bb7f6727d
Use correct types in default method
...
Motivation:
The default method we added for the MessageToByteEncoder has the incorrect parameter types and so is useless.
Modifications:
Fix type of parameter.
Result:
Default method match the protocol requirement.
2017-11-08 01:14:43 -08:00
Cory Benfield
7a7536d076
Add support for X.509 subject commonName.
2017-11-03 13:49:32 +00:00
Johannes Weiss
839a5050dd
ByteBuffer: fast path for contiguous collections
2017-11-03 02:39:54 -07:00
Norman Maurer
c22e5ead6b
Remove ByteBufferAllocator constructor argument from HttpResponseEncoder
...
Motivation:
We can allocate the buffer on the fly if needed, no need to add the constructor argument.
Modifications:
Just allocate the buffer in the methods itself that need it.
Result:
Easier to construct encoder and cleaner code.
2017-11-02 12:56:00 +01:00
Cory Benfield
4e04a275c0
Add internal support for subjectAltName
2017-11-01 17:46:56 +00:00
Cory Benfield
cffd11d4e8
Fix tests that do not expect IOData
2017-11-01 16:24:59 +00:00
Cory Benfield
6d8848d239
Omit chunked encoding for HTTP/1.0
2017-11-01 16:17:23 +00:00
Norman Maurer
22a35b2bdb
Add FileRegion support when using HTTP
...
Motivation:
Often people want to transfer large files over http which should be done using sendfile(...) for best performance.
Modifications:
- Add support for using FileRegion when sending body parts.
- Add tests
Result:
Be able to serve files without loading these into memory
2017-11-01 16:02:14 +01:00
Cory Benfield
8f2d17bc55
Break out common TLS events
2017-11-01 10:56:15 +00:00
Norman Maurer
a172546d7b
Use typesafe ChannelInboundHandler in IdleStateHandlerTest
2017-10-30 16:40:31 +01:00
Cory Benfield
8b860d3009
Add SNI handler
2017-10-30 10:58:26 +00:00
Norman Maurer
9c7829a065
Port IdleStateHandler from Netty
2017-10-29 09:46:48 +01:00
Johannes Weiß
6173bee782
Split IOData into NIOAny & IOData (ByteBuffer | FileRegion)
2017-10-25 19:31:27 +01:00
Cory Benfield
32c30074ea
Split client/server processing in OpenSSL
2017-10-24 16:41:23 +01:00
Johannes Weiss
e9c76088ac
ByteBuffer: avoid potential overflows for reading functions
2017-10-24 13:24:47 +01:00
Cory Benfield
25d57e8fab
Add Channel.isActive
2017-10-19 16:44:42 -07:00
Cory Benfield
b2cbe766f0
Add support for HTTP Upgrade
2017-10-12 17:24:00 -07:00
Johannes Weiss
cf352ac0c3
depend on OpenSSL properly
2017-10-19 19:51:42 +01:00
Cory Benfield
fb9e14b4d4
Don't lose promises on synchronous close.
2017-10-18 16:53:45 -07:00
Cory Benfield
7dddd67608
Add TLS configuration object
2017-09-29 14:25:46 +01:00
Tom Doron
f76a2bfa66
sort linux tests
...
motivation: generated linux tests dont have consitent sorting in different OSs
changes:
* change test generator to sort tests and imports in memory before writing to file
* update LinuxMain to the sorted version
2017-10-17 09:51:59 -07:00
Johannes Weiss
2889c7e3de
fix buffer confusion on incomplete writes
2017-10-17 16:51:15 +01:00
Cory Benfield
0803012b7a
Add support for retrieving headers in canonical form
2017-10-13 14:13:45 -07:00
Cory Benfield
2a7066873a
Add missing Linux tests
2017-10-13 15:02:22 -07:00
Cory Benfield
6f17b320d5
Ensure no transfer-encoding when body is forbidden
2017-10-13 13:44:51 -07:00
Johannes Weiss
3bef8a4012
turn `import Foundation` comments into code :)
2017-10-12 16:33:50 +01:00
Cory Benfield
1f52bac1f9
Add support for HTTP trailers
2017-10-04 13:49:03 +01:00