QGrpcHttp2Channel: use owning sendDATA interface in processQueue

Go up the chain and use the highest abstraction of the sendDATA
interfaces. Previously, we've been hit by internal QObject::deleteLater
calls for destroying the device in QtNetwork, which slowed down the
sending process. This has been fixed upstream, and all sendDATA
calls, except the QNCBD overload, now destroy the device immediately.

Reference: 4bc878ff4fbacd39d4c0ed1e8e742fd18fa74fed.

This version is now superior, as we don't have to create a new
connection just to destroy the device.

Pick-to: 6.9 6.8
Change-Id: I9416de25169fbaaa1657db7120987754699e4c00
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 7bac7883b7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Dennis Oberst 2025-06-25 17:54:55 +02:00 committed by Qt Cherry-pick Bot
parent db531a5739
commit 0da4fadb73
1 changed files with 3 additions and 10 deletions

View File

@ -615,16 +615,9 @@ void Http2Handler::processQueue()
if (m_queue.isEmpty())
return;
// Take ownership of the byte device.
auto *device = QNonContiguousByteDeviceFactory::create(m_queue.dequeue());
device->setParent(m_stream);
m_stream->sendDATA(device, device->atEnd() || m_endStreamAtFirstData);
// Manage the lifetime through the uploadFinished signal (or this
// Http2Handler). Don't use QObject::deleteLater here as this function is
// expensive and blocking. Delete the byte device directly.
// This is fine in this context.
connect(m_stream.get(), &QHttp2Stream::uploadFinished, device, [device] { delete device; });
const auto nextMessage = m_queue.dequeue();
const bool closeStream = nextMessage.isEmpty() || m_endStreamAtFirstData;
m_stream->sendDATA(nextMessage, closeStream);
}
bool Http2Handler::cancel()