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.
This commit is contained in:
Sönke Ludwig 2020-03-18 11:20:37 +01:00
parent 6c8b9c8e66
commit 73367273b5

View file

@ -770,8 +770,13 @@ mixin(tracer);
switch (res[1]) { switch (res[1]) {
default: default:
throw new Exception("Error writing data to socket."); throw new Exception("Error writing data to socket.");
case IOStatus.ok: break; case IOStatus.ok:
case IOStatus.disconnected: break; 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]; return res[2];