From ed0eb4ac74d28ecf71ef6254425989a215049816 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Wed, 30 Nov 2016 21:53:30 +0100 Subject: [PATCH] Fix epoll connection bugs --- source/tanya/async/event/epoll.d | 2 +- source/tanya/async/event/iocp.d | 6 +++--- source/tanya/async/event/kqueue.d | 16 ++++++++-------- source/tanya/async/event/selector.d | 4 ++-- source/tanya/async/loop.d | 5 +++-- source/tanya/async/package.d | 11 ++++------- 6 files changed, 21 insertions(+), 23 deletions(-) diff --git a/source/tanya/async/event/epoll.d b/source/tanya/async/event/epoll.d index 3451661..7fec708 100644 --- a/source/tanya/async/event/epoll.d +++ b/source/tanya/async/event/epoll.d @@ -107,7 +107,7 @@ class EpollLoop : SelectorLoop { if (errno != EINTR) { - throw defaultAllocator.make!BadLoopException(); + throw theAllocator.make!BadLoopException(); } return; } diff --git a/source/tanya/async/event/iocp.d b/source/tanya/async/event/iocp.d index 569f974..bcfda71 100644 --- a/source/tanya/async/event/iocp.d +++ b/source/tanya/async/event/iocp.d @@ -101,7 +101,7 @@ class IOCPLoop : Loop completionPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0); if (!completionPort) { - throw defaultAllocator.make!BadLoopException("Creating completion port failed"); + throw theAllocator.make!BadLoopException("Creating completion port failed"); } } @@ -141,7 +141,7 @@ class IOCPLoop : Loop catch (SocketException e) { MmapPool.instance.dispose(overlapped); - defaultAllocator.dispose(e); + theAllocator.dispose(e); return false; } } @@ -173,7 +173,7 @@ class IOCPLoop : Loop catch (SocketException e) { MmapPool.instance.dispose(overlapped); - defaultAllocator.dispose(e); + theAllocator.dispose(e); return false; } } diff --git a/source/tanya/async/event/kqueue.d b/source/tanya/async/event/kqueue.d index 37d9c1c..773ea12 100644 --- a/source/tanya/async/event/kqueue.d +++ b/source/tanya/async/event/kqueue.d @@ -127,13 +127,13 @@ else version (DragonFlyBSD) version (MacBSD): -import dlib.async.event.selector; -import dlib.async.loop; -import dlib.async.transport; -import dlib.async.watcher; -import dlib.memory; -import dlib.memory.mmappool; -import dlib.network.socket; +import tanya.async.event.selector; +import tanya.async.loop; +import tanya.async.transport; +import tanya.async.watcher; +import tanya.memory; +import tanya.memory.mmappool; +import tanya.network.socket; import core.stdc.errno; import core.sys.posix.unistd; import core.sys.posix.sys.time; @@ -250,7 +250,7 @@ class KqueueLoop : SelectorLoop { if (errno != EINTR) { - throw defaultAllocator.make!BadLoopException(); + throw theAllocator.make!BadLoopException(); } return; } diff --git a/source/tanya/async/event/selector.d b/source/tanya/async/event/selector.d index fa813d5..e9a103d 100644 --- a/source/tanya/async/event/selector.d +++ b/source/tanya/async/event/selector.d @@ -224,7 +224,7 @@ abstract class SelectorLoop : Loop } catch (SocketException e) { - defaultAllocator.dispose(e); + theAllocator.dispose(e); break; } if (client is null) @@ -235,7 +235,7 @@ abstract class SelectorLoop : Loop IOWatcher io; auto transport = MmapPool.instance.make!SelectorStreamTransport(this, client); - if (connections.length >= client.handle) + if (connections.length > client.handle) { io = cast(IOWatcher) connections[client.handle]; } diff --git a/source/tanya/async/loop.d b/source/tanya/async/loop.d index f34fedc..de1e401 100644 --- a/source/tanya/async/loop.d +++ b/source/tanya/async/loop.d @@ -26,7 +26,7 @@ * this.transport = transport; * } * - * void disconnected(SocketException exception = null) + * void disconnected(SocketException e = null) * { * } * } @@ -34,6 +34,7 @@ * void main() * { * auto address = new InternetAddress("127.0.0.1", cast(ushort) 8192); + * * version (Windows) * { * auto sock = new OverlappedStreamSocket(AddressFamily.INET); @@ -263,7 +264,7 @@ abstract class Loop protected void kill(IOWatcher watcher, SocketException exception) { watcher.socket.shutdown(); - defaultAllocator.dispose(watcher.socket); + theAllocator.dispose(watcher.socket); MmapPool.instance.dispose(watcher.transport); watcher.exception = exception; swapPendings.insertBack(watcher); diff --git a/source/tanya/async/package.d b/source/tanya/async/package.d index eb82f12..13c68ac 100644 --- a/source/tanya/async/package.d +++ b/source/tanya/async/package.d @@ -10,10 +10,7 @@ */ module tanya.async; -public -{ - import tanya.async.loop; - import tanya.async.protocol; - import tanya.async.transport; - import tanya.async.watcher; -} +public import tanya.async.loop; +public import tanya.async.protocol; +public import tanya.async.transport; +public import tanya.async.watcher;