Skip to content
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

NetworkTask: Distinguish implicit abort by timeout from explicit abort #10884

Closed
wants to merge 2 commits into from
Closed

NetworkTask: Distinguish implicit abort by timeout from explicit abort #10884

wants to merge 2 commits into from

Conversation

uklotzde
Copy link
Contributor

@uklotzde uklotzde commented Sep 9, 2022

A simple extension to prevent subversion of the state machine.

https://github.com/mixxxdj/mixxx/pull/10875/files#r965366266

@uklotzde uklotzde mentioned this pull request Sep 9, 2022
Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unclear what you are trying to fix with this PR. For my understanding, I have issued all your findings in the original PR

Part of a positive review culture is to point out issues and suggest improvements along the original PR. I would be happy to get back to this mode.
I treat the initial sentence as an unfounded insult to my work. I ask you to refrain from doing so immediately.

@@ -205,11 +205,15 @@ void WebTask::slotStart(int timeoutMillis, int delayMillis) {

auto* const pNetworkAccessManager = m_networkAccessManagerWeakPtr.data();
VERIFY_OR_DEBUG_ASSERT(pNetworkAccessManager) {
// Internally switch the state to pending as a prerequisite before
// invoking onNetworkError(). This is only required for technical
// reasons and the intermediate state will never become visible.
m_state = State::Pending;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting the state to Pending here is just a hack to pass the debug assertion in onNetworkError(). The correct solution is to change the state to State::Failed after the previous call fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree.

/// timedOut = false: The abort has been triggered explicitly.
/// timedOut = true: The abort has been triggered implicitly
/// after a client-side timeout expired.
virtual void slotAbort(bool timedOut) = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a code path to deliver timeouts to the calling code. Introducing here an anonymous boolean to pass a timeout a different way is unnecessary and raises the code complexity unnecessarily. In addition it exposes implementation details to the calling code. It violates also the code symmetry, because in case of all other error cause the error message is created in the NetworkTask and its derived classes all other Errors are passed in a generic way including a translated message and detailed error codes-

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is bikeshedding. I already wanted to mention that I was too lazy to introduce an enum class before getting feedback on the proposed solution. I assumed that this is obvious.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a code path to deliver timeouts to the calling code.

You still confuse client-side with server-side timeouts. A client-side timeout is an abort, but with an implicit instead of an explicit trigger. Technically, it is not an error, because the task did what you told it to do (according to the timeout parameter provided when starting it). A server-side timeout is an unexpected outcome and an error.

Aborting a request might subsequently let your business code fail. But that's a different level of abstraction.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is bikeshedding.

Seriously @uklotzde ? Please treat me with respect!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The client side timeout is an network error in the same way as the server side timeout. There is no need to pass one over a different signal than the other. In contrast the slotAbort is a direct responds to an explicit immediately abort request. Using that for a Network was wrong and causes the bug I have fixed.

But anyway this is an implementation detail f the bug fix.

You have not explained why you experience a bug with it.

@uklotzde
Copy link
Contributor Author

uklotzde commented Sep 9, 2022

It is unclear what you are trying to fix with this PR. For my understanding, I have issued all your findings in the original PR

Part of a positive review culture is to point out issues and suggest improvements along the original PR. I would be happy to get back to this mode. I treat the initial sentence as an unfounded insult to my work. I ask you to refrain from doing so immediately.

#10875 (comment)

Or are you prepared to overrule this PR with your one, like the previous one?

@uklotzde uklotzde closed this Nov 5, 2022
@uklotzde uklotzde deleted the network-task-abort-by-timeout branch November 5, 2022 11:10
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 this pull request may close these issues.

2 participants