SSH: Fix send buffer flushing.

There might be more data to send than what fits into one packet. This
case was not handled correctly.

Change-Id: I5a415223c37ec8a041503d901bbcc81e903f46d9
Reviewed-by: Daniel Molkentin <daniel.molkentin@nokia.com>
This commit is contained in:
Christian Kandeler
2012-06-06 15:16:03 +02:00
committed by Daniel Molkentin
parent cc35259431
commit 3e809de1cf

View File

@@ -116,9 +116,11 @@ void AbstractSshChannel::handleWindowAdjust(quint32 bytesToAdd)
void AbstractSshChannel::flushSendBuffer()
{
const quint32 bytesToSend = qMin(m_remoteMaxPacketSize,
qMin<quint32>(m_remoteWindowSize, m_sendBuffer.size()));
if (bytesToSend > 0) {
while (true) {
const quint32 bytesToSend = qMin(m_remoteMaxPacketSize,
qMin<quint32>(m_remoteWindowSize, m_sendBuffer.size()));
if (bytesToSend == 0)
break;
const QByteArray &data = m_sendBuffer.left(bytesToSend);
m_sendFacility.sendChannelDataPacket(m_remoteChannel, data);
m_sendBuffer.remove(0, bytesToSend);