diff --git a/source/eventcore/drivers/posix/cfrunloop.d b/source/eventcore/drivers/posix/cfrunloop.d index 8fc7b45..03da675 100644 --- a/source/eventcore/drivers/posix/cfrunloop.d +++ b/source/eventcore/drivers/posix/cfrunloop.d @@ -38,7 +38,7 @@ final class CFRunLoopEventLoop : KqueueEventLoopBase { CFFileDescriptorEnableCallBacks(m_kqueueDescriptor, CFOptionFlags.kCFFileDescriptorReadCallBack); m_kqueueSource = CFFileDescriptorCreateRunLoopSource(kCFAllocatorDefault, m_kqueueDescriptor, 0); - CFRunLoopAddSource(CFRunLoopGetMain(), m_kqueueSource, kCFRunLoopDefaultMode); + CFRunLoopAddSource(CFRunLoopGetCurrent(), m_kqueueSource, kCFRunLoopDefaultMode); } override bool doProcessEvents(Duration timeout) diff --git a/source/eventcore/drivers/posix/sockets.d b/source/eventcore/drivers/posix/sockets.d index 1f8557a..ee27eea 100644 --- a/source/eventcore/drivers/posix/sockets.d +++ b/source/eventcore/drivers/posix/sockets.d @@ -851,7 +851,11 @@ final class PosixEventDriverSockets(Loop : PosixEventLoop) : EventDriverSockets } scope src_addrc = new RefAddress(() @trusted { return cast(sockaddr*)&src_addr; } (), src_addr_len); - on_receive_finish(socket, IOStatus.ok, ret, src_addrc); + if (ret == 0) { + on_receive_finish(socket, IOStatus.disconnected, 0, src_addrc); + } else { + on_receive_finish(socket, IOStatus.ok, ret, src_addrc); + } } package void receiveNoGC(DatagramSocketFD socket, ubyte[] buffer, IOMode mode, void delegate(DatagramSocketFD, IOStatus, size_t, scope RefAddress) @safe nothrow @nogc on_receive_finish) diff --git a/source/eventcore/drivers/posix/watchers.d b/source/eventcore/drivers/posix/watchers.d index 4ad8ce3..d2fd2a0 100644 --- a/source/eventcore/drivers/posix/watchers.d +++ b/source/eventcore/drivers/posix/watchers.d @@ -391,7 +391,7 @@ final class FSEventsEventDriverWatchers(Events : EventDriverEvents) : EventDrive slot.stream = FSEventStreamCreate(null, &onFSEvent, () @trusted { return &ctx; } (), paths, since_when, 0.1, kFSEventStreamCreateFlagFileEvents|kFSEventStreamCreateFlagNoDefer); - FSEventStreamScheduleWithRunLoop(slot.stream, CFRunLoopGetMain(), kCFRunLoopDefaultMode); + FSEventStreamScheduleWithRunLoop(slot.stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); FSEventStreamStart(slot.stream); m_streamMap[cast(void*)slot.stream] = slot.id; diff --git a/source/eventcore/internal/corefoundation.d b/source/eventcore/internal/corefoundation.d index b893d0e..d7757c3 100644 --- a/source/eventcore/internal/corefoundation.d +++ b/source/eventcore/internal/corefoundation.d @@ -93,6 +93,7 @@ static if (!is(CFRunLoopRef)) { extern const CFStringRef kCFRunLoopCommonModes; CFRunLoopRef CFRunLoopGetMain() @nogc; + CFRunLoopRef CFRunLoopGetCurrent() @nogc; void CFRunLoopAddSource(CFRunLoopRef rl, CFRunLoopSourceRef source, CFRunLoopMode mode) @nogc; CFRunLoopRunResult CFRunLoopRunInMode(CFRunLoopMode mode, CFTimeInterval seconds, Boolean returnAfterSourceHandled); }