From 0da4fadb73b9310cd73008ecf31ca392f07a10ce Mon Sep 17 00:00:00 2001 From: Dennis Oberst Date: Wed, 25 Jun 2025 17:54:55 +0200 Subject: [PATCH] QGrpcHttp2Channel: use owning sendDATA interface in processQueue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: MÃ¥rten Nordheim (cherry picked from commit 7bac7883b72e131b5bddd565fdab1bb83ded2a49) Reviewed-by: Qt Cherry-pick Bot --- src/grpc/qgrpchttp2channel.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/grpc/qgrpchttp2channel.cpp b/src/grpc/qgrpchttp2channel.cpp index 4cc1a000..4d9403a4 100644 --- a/src/grpc/qgrpchttp2channel.cpp +++ b/src/grpc/qgrpchttp2channel.cpp @@ -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()