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)
{
throw defaultAllocator.make!BadLoopException();
throw theAllocator.make!BadLoopException();
}
return;
}

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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];
}

View File

@ -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);

View File

@ -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;