Commit Graph
1415 Commits
Author SHA1 Message Date
Norman Maurer fc3359f40f Introduce ChannelError and use it for different cases 2017-05-23 15:35:05 +02:00
Norman Maurer f933093a1e Introduce ServerSocketChannel which will accept SocketChannel instances. Now the ServerSocket and the Socket are both handled directly via the EventLoop and make use of the pipeline just like in Netty. 2017-05-23 14:53:21 +02:00
Norman Maurer b33ad4b572 Add data set/get/write/read methods to ByteBuffer 2017-05-22 19:33:38 +02:00
Norman Maurer 3b0f013a6e Add slice(...) methods to ByteBuffer and fix a few bugs 2017-05-22 17:17:54 +02:00
Johannes Weiß ad1196f275 use swift-errno instead of duplicating the code 2017-05-22 16:24:41 +01:00
Norman Maurer 9286f4e221 Add methods to get / read / set / write Integer types to ByteBuffer 2017-05-22 13:57:49 +02:00
Norman Maurer 8ee1f99707 Only call fireChannelRegistered if the Channel was registered before 2017-05-21 09:10:14 +02:00
Norman Maurer 38edbe0f19 Simplify PendingWrites.consumeMultiple and add a few more asserts 2017-05-21 09:03:55 +02:00
Norman Maurer 5a9f8eab28 Make use of try? syntax and ensure we pass the correct Error to close0 all the time 2017-05-21 08:42:32 +02:00
Norman Maurer 44e78dd7e8 Use UIO_MAXIOV to calculate the writev limit on linux 2017-05-20 21:05:27 +02:00
Norman Maurer 275e69be63 Add support for gathering writes to Socket and also ensure Channel will automatically use gathering writes if you call Channel*.write multiple times followed by a flush.
Beside this I removed the Socket.write and Socket.read method that takes an offset as these are redundant with just pass in a subrange of Data.
2017-05-19 15:28:15 +02:00
Norman Maurer 5371cb649f Simplify code that fails all pending writes on close and ensure correct ordering of events 2017-05-19 21:26:03 +02:00
Norman Maurer 15eef4c0af Expose remote / local SocketAddress on Channel 2017-05-19 21:07:04 +02:00
Norman Maurer 461e82634d Ensure we deregister the Socket before call close so we never receive an EBADF 2017-05-19 20:36:56 +02:00
Norman Maurer d28a7573de Make swift-nio compile on linux as well 2017-05-19 20:34:12 +02:00
Norman Maurer 0427eaff33 Add support for Channel.bind(...), this will also be needed once we support the ServerSocket via a Channel 2017-05-19 08:21:55 +02:00
Johannes Weiß 8fb1162a7e fix missing constructor parameters 2017-05-19 00:03:06 +01:00
Norman Maurer 75a2c0bc49 Use linked-list datastructure to hold the pending writes. This gives some nice performance boost and better latency as well. 2017-05-18 22:51:17 +02:00
Johannes Weiß 2275423803 fix illegal buffer being passed to kernel (Data wasn't allocated yet) 2017-05-18 15:42:00 +01:00
Johannes Weiß 5bd5e887ae remove a bunch of unnecessary code 2017-05-18 15:45:52 +01:00
Norman Maurer a5323174dc Ensure we not leak the buffer and promise when EWOULDBLOCK is returned from write 2017-05-18 15:52:31 +02:00
Norman Maurer 54e510cbb8 Use lazy init as we need to pass in self to ChannelPipeline 2017-05-18 12:22:02 +02:00
Norman Maurer 08507cb47d Update to new Future-Swift tag and ensure we not leak Promises (as Future-Swift will enforce this) 2017-05-18 14:10:53 +02:00
Norman Maurer 63a8311349 Correctly forward all Errors through the ChannelPipeline and also fail hard if the user tries to use the ChannelHandlerContext after it was removed from the ChannelPipeline 2017-05-18 12:40:18 +02:00
Norman Maurer 83d1f86efb Introduce ChannelOption and use it to set / get config values 2017-05-18 07:35:55 +02:00
Norman Maurer 66c02bf30b Ensure the EventLoop is currently only accessed from the same thread 2017-05-18 08:58:47 +02:00
Norman Maurer 3536fc1e62 Use static instances when possible to reduce memory usage and also allow to access Channel via ChannelPipeline 2017-05-17 19:30:21 +02:00
Johannes Weiß ba5bf60aee Channel owns ChannelPipeline and ChannelConfig
So `Channel -[strong]-> ChannelPipeline` and for the way back `ChannelPipeline -[unowned]-> Channel`
2017-05-17 17:40:51 +01:00
Johannes Weiß f3ad6c308e deallocate correct events capacity
Previously we allocated 2048 events and deallocated 1, fixed now.
2017-05-17 17:57:18 +01:00
Norman Maurer d462b007d7 Remove backpressure handling from Channel itself and implement it in a generic ChannelHandler, this makes it more flexible for the user what to do 2017-05-17 09:40:44 +02:00
Norman Maurer fa979932e4 Remove some unnecessary assignments 2017-05-17 08:22:50 +02:00
Norman Maurer 8b0f2b68d9 Ensure we not leak promise on write failure (which mean result in memory leak). This was introduced by 7be608fcda47ed06051dc188d5e5b8bee56b8d68 2017-05-16 14:59:50 +02:00
Norman Maurer 51764e1c6c Ensure Buffer.withMutable*Pointer returns an optional so its possible to signal back that a Socket can not read / write anymore 2017-05-16 11:38:36 +02:00
Norman Maurer 76a88539f7 More consistent naming by change RecvBufferAllocator to RecvByteBufferAllocator 2017-05-16 08:23:36 +02:00
Norman Maurer a256f4a424 Simplify and rearrange 2017-05-16 08:21:57 +02:00
Kevin Clark 7ef823a44a Port ByteBuf
This implements a heap based ByteBuffer modeled on Netty's ByteBuf. It provides read and write access via Unsafe{Mutable}Pointers (withReadPointer, withMutableWritePointer) and read access via withData. Instead of providing public access to mutating readIndex/writeIndex, the mutable withPointer methods take a closure returning the number of bytes written and automatically manages the applicable index.

Read and write helper methods still largely TODO.
2017-05-15 22:30:49 -07:00
Norman Maurer bb6cb9fa81 Simplify code which uses enums 2017-05-15 22:46:53 +02:00
Norman Maurer 4b4c3c2dbd Simplify eventloop handling 2017-05-15 22:42:36 +02:00
Norman Maurer 4336761b54 Correctly also handle EPOLLRDHUP 2017-05-15 22:35:19 +02:00
Norman Maurer 18a844a633 Cleaner handling for registering for InterestedEvents 2017-05-15 22:32:52 +02:00
Norman Maurer 13b7b61b9a Ensure we correctly handle EOF when read and also that we never re-register when the Channel was closed 2017-05-15 20:26:07 +02:00
Norman Maurer a4fc805685 Ensure we not re-register on the eventLoop once the channel was already closed 2017-05-15 19:32:08 +02:00
Norman Maurer ec16d01c7c Move ChannelHandlerContext class to ChannelPipeline.swift to be able to use fileprivate. 2017-05-15 11:46:29 +02:00
Norman Maurer f6762500bb Fix reference-cycles by using weak declarations 2017-05-15 11:35:17 +02:00
Norman Maurer d626e49b2f Make inEventLoop a property 2017-05-14 21:09:46 +02:00
Norman Maurer 466e16b2e4 Fix runtime error 2017-05-14 21:08:56 +02:00
Norman Maurer d839ed1c52 Remove a few reference-cycles and so memory leaks 2017-05-14 20:41:38 +02:00
Norman Maurer 53fe94869f Replace AnyObject with Any to allow passing classes and structs through the pipeline 2017-05-12 19:10:23 +02:00
Norman Maurer 3565a4b8df Use RecvBufferAllocator that is set in ChannelConfig 2017-05-11 19:43:48 +02:00
Norman Maurer 7433a94743 Some visibility cleanup 2017-05-11 17:29:56 +02:00