[go: nahoru, domu]

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

Websock API cleanup #1782

Merged
merged 18 commits into from
Jun 30, 2023
Merged

Websock API cleanup #1782

merged 18 commits into from
Jun 30, 2023

Conversation

CendioOssman
Copy link
Member

More clean-up as a result of playing around with async functions. Follow-up to #1780.

We don't have to keep track of this much data between rects, so
restructure things to make it more simple. This allows the JPEG parsing
code to be a pure function which only depends on the input.
We don't need any full slice functionality, so let's change this to
better march rQpeek8() and rQshiftBytes().
That is the modern way to handle operations that cannot complete
immediately.
Use proper accessor functions instead of poking around in internal
buffers.
Callers should be using rQwait() to ensure sufficient data is present,
and not poke around in the internal buffering.
Callers should be properly aware of how much data they need, as they
need to call rQwait() first to ensure the data is present.
Let's not duplicate this stuff when we have convenience functions.
@CendioOssman CendioOssman requested a review from samhed June 4, 2023 17:01
We don't know how long the caller will hang on to this data, so we need
to be safe by default and assume it will kept indefinitely. That means
we can't return a reference to the internal buffer, as that will get
overwritten with future messages.

We want to avoid unnecessary copying in performance critical code,
though. So allow code to explicitly ask for a shared buffer, assuming
they know the data needs to be consumed immediately.
This is what we almost always want, and this makes it consistent with
rQshift8() and rQshift16().
We are expected to preserve these and use them in our requests back to
the server. We can't do that if we don't actually decode them correctly.
We don't know the server layout yet, so we can't preserve the screen id
or flags yet at this point. Move it until after we've parsed everything.
Send real messages and avoid poking around in internals, as we weren't
testing things correctly that way.
It takes too much time and can make the tests fail.
Makes for more robust and realistic tests.
There is no encoding/decoding in modern WebSockets, so let's clean up
some of the old crud that no longer serves a purpose.
It's more robust to do this just before we need the space, rather than
assume when the queue will be read and adjust things right after.
Callers shouldn't be poking around directly in to the send queue, but
should use accessor functions like for the read queue.
Callers shouldn't have to deal with the internal buffering limits of
Websock, so implicitly flush the buffer if more room is needed.
Copy link
Member
@samhed samhed left a comment

Choose a reason for hiding this comment

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

Nice cleanup. Looks good!

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.

None yet

2 participants