diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-09-09 12:20:49 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-09-10 08:40:01 +0200 |
commit | b30559565cb91501baddea495362101341a0aa22 (patch) | |
tree | 9704a0c2c48ae0219f40393125c0c9934de2831d | |
parent | 1d98fad6ea411a00812d52bb7119f651b499d7a9 (diff) | |
download | qtwebengine-b30559565cb91501baddea495362101341a0aa22.tar.gz |
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.
Pick-to: 6.4 6.4.0 6.3
Task-number: QTBUG-106461
Change-Id: Ia381db338adb1b1994d1da9b50c6d6ff542ea3e5
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
-rw-r--r-- | src/core/net/custom_url_loader_factory.cpp | 11 |
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 d879ae478..9873b979a 100644 --- a/src/core/net/custom_url_loader_factory.cpp +++ b/src/core/net/custom_url_loader_factory.cpp @@ -290,15 +290,14 @@ private: m_client->OnStartLoadingResponseBody(std::move(m_pipeConsumerHandle)); 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_pipeProducerHandle.get(), MOJO_HANDLE_SIGNAL_WRITABLE, MOJO_WATCH_CONDITION_SATISFIED, base::BindRepeating(&CustomURLLoader::notifyReadyWrite, m_weakPtrFactory.GetWeakPtr())); + + readAvailableData(); // May delete this } void notifyCanceled() override { @@ -366,8 +365,10 @@ private: uint32_t bufferSize = 0; MojoResult beginResult = m_pipeProducerHandle->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()}) |