summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-09-09 12:20:49 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-09-12 11:45:46 +0200
commit34363b9c0528e4a6920581e10c68eec44bbd470a (patch)
tree0c6e225ca16b279b89dac0ca5390a2d33bba2765
parent2291526b04a09e126eff5785bbfb869b223c7fa2 (diff)
Fix busy waiting on streaming QIODevice's
The writable watcher will trigger all the time if we use automatic arming, instead we need to arm it manually when it is needed. Task-number: QTBUG-106461 Change-Id: Ia381db338adb1b1994d1da9b50c6d6ff542ea3e5 Reviewed-by: Michal Klocek <michal.klocek@qt.io> (cherry picked from commit b30559565cb91501baddea495362101341a0aa22)
-rw-r--r--src/core/net/custom_url_loader_factory.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/core/net/custom_url_loader_factory.cpp b/src/core/net/custom_url_loader_factory.cpp
index 10b4a9e0f..c7426a5b9 100644
--- a/src/core/net/custom_url_loader_factory.cpp
+++ b/src/core/net/custom_url_loader_factory.cpp
@@ -310,15 +310,14 @@ private:
m_client->OnStartLoadingResponseBody(std::move(m_pipe.consumer_handle));
m_head = nullptr;
- if (readAvailableData()) // May delete this
- return;
-
m_watcher = std::make_unique<mojo::SimpleWatcher>(
- FROM_HERE, mojo::SimpleWatcher::ArmingPolicy::AUTOMATIC, m_taskRunner);
+ FROM_HERE, mojo::SimpleWatcher::ArmingPolicy::MANUAL, m_taskRunner);
m_watcher->Watch(m_pipe.producer_handle.get(), MOJO_HANDLE_SIGNAL_WRITABLE,
MOJO_WATCH_CONDITION_SATISFIED,
base::BindRepeating(&CustomURLLoader::notifyReadyWrite,
m_weakPtrFactory.GetWeakPtr()));
+
+ readAvailableData(); // May delete this
}
void notifyCanceled() override
{
@@ -386,8 +385,10 @@ private:
uint32_t bufferSize = 0;
MojoResult beginResult = m_pipe.producer_handle->BeginWriteData(
&buffer, &bufferSize, MOJO_BEGIN_WRITE_DATA_FLAG_NONE);
- if (beginResult == MOJO_RESULT_SHOULD_WAIT)
+ if (beginResult == MOJO_RESULT_SHOULD_WAIT) {
+ m_watcher->ArmOrNotify();
return false; // Wait for pipe watcher
+ }
if (beginResult != MOJO_RESULT_OK)
break;
if (m_maxBytesToRead > 0 && m_maxBytesToRead <= int64_t{std::numeric_limits<uint32_t>::max()})