Fix possible hang after partial socket reads.
This commit is contained in:
parent
5c4e8be20a
commit
7c3fdc5ddf
|
@ -455,6 +455,7 @@ final class PosixEventDriverSockets(Loop : PosixEventLoop) : EventDriverSockets
|
||||||
assert(m_loop.m_fds[socket].common.refCount > 0);
|
assert(m_loop.m_fds[socket].common.refCount > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (true) {
|
||||||
sizediff_t ret = 0;
|
sizediff_t ret = 0;
|
||||||
() @trusted { ret = .recv(cast(sock_t)socket, slot.readBuffer.ptr, min(slot.readBuffer.length, int.max), 0); } ();
|
() @trusted { ret = .recv(cast(sock_t)socket, slot.readBuffer.ptr, min(slot.readBuffer.length, int.max), 0); } ();
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -481,6 +482,11 @@ final class PosixEventDriverSockets(Loop : PosixEventLoop) : EventDriverSockets
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// retry if this was just a partial read, as it could mean that
|
||||||
|
// the connection was closed by the remove peer
|
||||||
|
if (ret <= 0 || !slot.readBuffer.length) break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IOStatus handleReadError(int err, ref StreamSocketSlot slot)
|
private static IOStatus handleReadError(int err, ref StreamSocketSlot slot)
|
||||||
|
|
Loading…
Reference in a new issue