From 73367273b5b9446069ff9d709305b13d885b80aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Wed, 18 Mar 2020 11:20:37 +0100 Subject: [PATCH] Fix behavior of TCPConnection.write when the connection gets closed half-way trough. Should throw an exception in case of IOMode.all, but actually returned a partial result. --- source/vibe/core/net.d | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/vibe/core/net.d b/source/vibe/core/net.d index 8968cfe..86cc541 100644 --- a/source/vibe/core/net.d +++ b/source/vibe/core/net.d @@ -770,8 +770,13 @@ mixin(tracer); switch (res[1]) { default: throw new Exception("Error writing data to socket."); - case IOStatus.ok: break; - case IOStatus.disconnected: break; + case IOStatus.ok: + assert(mode != IOMode.all || res[2] == bytes.length); + break; + case IOStatus.disconnected: + if (mode == IOMode.all && res[2] != bytes.length) + throw new Exception("Connection closed while writing data."); + break; } return res[2];