Fix epoll connection bugs

This commit is contained in:
Eugen Wissner 2016-11-30 21:53:30 +01:00
parent 192ee20bf7
commit ed0eb4ac74
6 changed files with 21 additions and 23 deletions

View File

@ -107,7 +107,7 @@ class EpollLoop : SelectorLoop
{ {
if (errno != EINTR) if (errno != EINTR)
{ {
throw defaultAllocator.make!BadLoopException(); throw theAllocator.make!BadLoopException();
} }
return; return;
} }

View File

@ -101,7 +101,7 @@ class IOCPLoop : Loop
completionPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0); completionPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);
if (!completionPort) 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) catch (SocketException e)
{ {
MmapPool.instance.dispose(overlapped); MmapPool.instance.dispose(overlapped);
defaultAllocator.dispose(e); theAllocator.dispose(e);
return false; return false;
} }
} }
@ -173,7 +173,7 @@ class IOCPLoop : Loop
catch (SocketException e) catch (SocketException e)
{ {
MmapPool.instance.dispose(overlapped); MmapPool.instance.dispose(overlapped);
defaultAllocator.dispose(e); theAllocator.dispose(e);
return false; return false;
} }
} }

View File

@ -127,13 +127,13 @@ else version (DragonFlyBSD)
version (MacBSD): version (MacBSD):
import dlib.async.event.selector; import tanya.async.event.selector;
import dlib.async.loop; import tanya.async.loop;
import dlib.async.transport; import tanya.async.transport;
import dlib.async.watcher; import tanya.async.watcher;
import dlib.memory; import tanya.memory;
import dlib.memory.mmappool; import tanya.memory.mmappool;
import dlib.network.socket; import tanya.network.socket;
import core.stdc.errno; import core.stdc.errno;
import core.sys.posix.unistd; import core.sys.posix.unistd;
import core.sys.posix.sys.time; import core.sys.posix.sys.time;
@ -250,7 +250,7 @@ class KqueueLoop : SelectorLoop
{ {
if (errno != EINTR) if (errno != EINTR)
{ {
throw defaultAllocator.make!BadLoopException(); throw theAllocator.make!BadLoopException();
} }
return; return;
} }

View File

@ -224,7 +224,7 @@ abstract class SelectorLoop : Loop
} }
catch (SocketException e) catch (SocketException e)
{ {
defaultAllocator.dispose(e); theAllocator.dispose(e);
break; break;
} }
if (client is null) if (client is null)
@ -235,7 +235,7 @@ abstract class SelectorLoop : Loop
IOWatcher io; IOWatcher io;
auto transport = MmapPool.instance.make!SelectorStreamTransport(this, client); auto transport = MmapPool.instance.make!SelectorStreamTransport(this, client);
if (connections.length >= client.handle) if (connections.length > client.handle)
{ {
io = cast(IOWatcher) connections[client.handle]; io = cast(IOWatcher) connections[client.handle];
} }

View File

@ -26,7 +26,7 @@
* this.transport = transport; * this.transport = transport;
* } * }
* *
* void disconnected(SocketException exception = null) * void disconnected(SocketException e = null)
* { * {
* } * }
* } * }
@ -34,6 +34,7 @@
* void main() * void main()
* { * {
* auto address = new InternetAddress("127.0.0.1", cast(ushort) 8192); * auto address = new InternetAddress("127.0.0.1", cast(ushort) 8192);
*
* version (Windows) * version (Windows)
* { * {
* auto sock = new OverlappedStreamSocket(AddressFamily.INET); * auto sock = new OverlappedStreamSocket(AddressFamily.INET);
@ -263,7 +264,7 @@ abstract class Loop
protected void kill(IOWatcher watcher, SocketException exception) protected void kill(IOWatcher watcher, SocketException exception)
{ {
watcher.socket.shutdown(); watcher.socket.shutdown();
defaultAllocator.dispose(watcher.socket); theAllocator.dispose(watcher.socket);
MmapPool.instance.dispose(watcher.transport); MmapPool.instance.dispose(watcher.transport);
watcher.exception = exception; watcher.exception = exception;
swapPendings.insertBack(watcher); swapPendings.insertBack(watcher);

View File

@ -10,10 +10,7 @@
*/ */
module tanya.async; module tanya.async;
public public import tanya.async.loop;
{ public import tanya.async.protocol;
import tanya.async.loop; public import tanya.async.transport;
import tanya.async.protocol; public import tanya.async.watcher;
import tanya.async.transport;
import tanya.async.watcher;
}