Fix compressed buffer not being emptied instantly in TcpPacketSocket::writeData

would only cause an issue when using sendAll, resulted in rarely not connecting
This commit is contained in:
Kae 2024-07-27 08:43:32 +10:00
parent 2d278e71c1
commit c3de15c18d

View File

@ -285,12 +285,14 @@ bool TcpPacketSocket::writeData() {
m_outputBuffer.clear(); m_outputBuffer.clear();
m_compressedBuffer.append(compressed.ptr(), compressed.size()); m_compressedBuffer.append(compressed.ptr(), compressed.size());
size_t written = m_socket->send(m_compressedBuffer.ptr(), m_compressedBuffer.size()); do {
if (written > 0) { size_t written = m_socket->send(m_compressedBuffer.ptr(), m_compressedBuffer.size());
dataSent = true; if (written > 0) {
m_compressedBuffer.trimLeft(written); dataSent = true;
m_outgoingStats.mix(written); m_compressedBuffer.trimLeft(written);
} m_outgoingStats.mix(written);
}
} while (!m_compressedBuffer.empty());
} else { } else {
do { do {
size_t written = m_socket->send(m_outputBuffer.ptr(), m_outputBuffer.size()); size_t written = m_socket->send(m_outputBuffer.ptr(), m_outputBuffer.size());