Fix transferred byte counter for windows stream socket reads/writes.
Fixes read/write sizes that are sometimes reported too small.
This commit is contained in:
parent
f301e479a4
commit
e8ed523c08
|
@ -249,6 +249,7 @@ final class WinAPIEventDriverSockets : EventDriverSockets {
|
||||||
{
|
{
|
||||||
auto slot = () @trusted { return &m_sockets[socket].streamSocket(); } ();
|
auto slot = () @trusted { return &m_sockets[socket].streamSocket(); } ();
|
||||||
slot.read.buffer = buffer;
|
slot.read.buffer = buffer;
|
||||||
|
slot.read.bytesTransferred = 0;
|
||||||
slot.read.mode = mode;
|
slot.read.mode = mode;
|
||||||
slot.read.wsabuf[0].len = buffer.length;
|
slot.read.wsabuf[0].len = buffer.length;
|
||||||
slot.read.wsabuf[0].buf = () @trusted { return buffer.ptr; } ();
|
slot.read.wsabuf[0].buf = () @trusted { return buffer.ptr; } ();
|
||||||
|
@ -306,7 +307,7 @@ final class WinAPIEventDriverSockets : EventDriverSockets {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slot.streamSocket.read.mode == IOMode.once || !slot.streamSocket.read.buffer.length) {
|
if (slot.streamSocket.read.mode == IOMode.once || !slot.streamSocket.read.buffer.length) {
|
||||||
invokeCallback(IOStatus.ok, cbTransferred);
|
invokeCallback(IOStatus.ok, slot.streamSocket.read.bytesTransferred);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,6 +333,7 @@ final class WinAPIEventDriverSockets : EventDriverSockets {
|
||||||
{
|
{
|
||||||
auto slot = () @trusted { return &m_sockets[socket].streamSocket(); } ();
|
auto slot = () @trusted { return &m_sockets[socket].streamSocket(); } ();
|
||||||
slot.write.buffer = buffer;
|
slot.write.buffer = buffer;
|
||||||
|
slot.write.bytesTransferred = 0;
|
||||||
slot.write.mode = mode;
|
slot.write.mode = mode;
|
||||||
slot.write.wsabuf[0].len = buffer.length;
|
slot.write.wsabuf[0].len = buffer.length;
|
||||||
slot.write.wsabuf[0].buf = () @trusted { return cast(ubyte*)buffer.ptr; } ();
|
slot.write.wsabuf[0].buf = () @trusted { return cast(ubyte*)buffer.ptr; } ();
|
||||||
|
@ -381,7 +383,7 @@ final class WinAPIEventDriverSockets : EventDriverSockets {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slot.streamSocket.write.mode == IOMode.once || !slot.streamSocket.write.buffer.length) {
|
if (slot.streamSocket.write.mode == IOMode.once || !slot.streamSocket.write.buffer.length) {
|
||||||
invokeCallback(IOStatus.ok, cbTransferred);
|
invokeCallback(IOStatus.ok, slot.streamSocket.write.bytesTransferred);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -854,8 +856,7 @@ final class WinAPIEventDriverSockets : EventDriverSockets {
|
||||||
cb(cast(StreamSocketFD)sock, ConnectStatus.refused);
|
cb(cast(StreamSocketFD)sock, ConnectStatus.refused);
|
||||||
} else {
|
} else {
|
||||||
slot.streamSocket.state = ConnectionState.connected;
|
slot.streamSocket.state = ConnectionState.connected;
|
||||||
if (slot.common.driver.releaseRef(cast(StreamSocketFD)sock))
|
cb(cast(StreamSocketFD)sock, ConnectStatus.connected);
|
||||||
cb(cast(StreamSocketFD)sock, ConnectStatus.connected);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FD_READ:
|
case FD_READ:
|
||||||
|
|
Loading…
Reference in a new issue