From 194667a99f28c35a90db2c103777e466bb19778c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Mon, 25 May 2020 14:37:55 +0200 Subject: [PATCH] Fix reported status for disconnected message based Unix sockets. Was reporting IOStatus.ok for a connection that was disconnected, possibly resulting in an endless loop (or recursion) of trying to read another (apparently zero sized) packet. --- source/eventcore/drivers/posix/sockets.d | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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)