8000 Illogical result of the `write` function. · Issue #211 · qcoro/qcoro · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Illogical result of the write function. #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pefedotov opened this issue Feb 21, 2024 · 0 comments · Fi 8000 xed by #212
Closed

Illogical result of the write function. #211

pefedotov opened this issue Feb 21, 2024 · 0 comments · Fixed by #212

Comments

@pefedotov
Copy link

The write function is defined in the QIODevice class. It should, according to the documentation, return the number of bytes written. But, instead of the number of bytes, it returns the number of bytes not written!
The contents of the write function are shown below

QCoro::Task<qint64> QCoroIODevice::write(const QByteArray &buffer) {
     auto bytesWritten = mDevice->write(buffer);
     while (bytesWritten > 0) {
         const auto flushed = co_await waitForBytesWritten(-1);
         bytesWritten -= flushed.value();
     }

     co_return bytesWritten;
}

As you can see, the number of bytes is constantly decreasing and if successful, the result of the function will be 0.
This is definitely not the number of bytes written.

danvratil added a commit that referenced this issue Feb 21, 2024
The function would always return 0 instead of the actual bytes
that have been written.
@danvratil danvratil linked a pull request Feb 21, 2024 that will close this issue
danvratil added a commit that referenced this issue Feb 21, 2024
The function would always return 0 instead of the actual bytes
that have been written.
danvratil added a commit that referenced this issue Feb 21, 2024
Fix wrong result of QCoroIODevice::write() (fixes #211)
4E64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant
0