Skip to content

Conversation

@vonzshik
Copy link
Contributor

Related to #3775

Testing whether it breaks something...

@vonzshik vonzshik requested a review from roji as a code owner May 24, 2021 13:28
Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

Thanks for doing this @vonzshik.

When I thought about how to do it, I imagined a more explicit/high-level API where we would call "StartNewFrame" on the buffer, providing the message code and length, rather than inferring that a new frame is starting from the setting of ReadPosition (when _inFrame is false). It seems like this might considerably simplify things (I'm still not clear on the exact logic of _bufferReset, ResetFrame, etc.).

What do you think?

await Authenticate(username, timeout, async, cancellationToken);

#if DEBUG
ReadBuffer.EnableFrameTracking = true;
Copy link
Member

Choose a reason for hiding this comment

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

Any particular reason this shouldn't always be on (in DEBUG)? We could also use it to catch bugs in the Startup message and in authentication...

{
await Authenticate(username, timeout, async, cancellationToken);

#if DEBUG
Copy link
Member

Choose a reason for hiding this comment

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

Rather than wrapping each call with #if DEBUG, the methods themselves can have [Conditional("DEBUG")]. This automatically does what we want, and makes the call sites much nicer.

}
else
{
_currentFrame.LengthLeft -= positionDelta;
Copy link
Member

Choose a reason for hiding this comment

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

nit: maybe better to have Position (in the frame) - just like the the buffer's ReadPosition - which gets incremented, rather than LengthLeft which gets decremented.

{
Debug.Assert(positionDelta == 1, "Protocol failure");
Debug.Assert(ReadBytesLeft >= 5);
var frameCode = Buffer[_readPosition];
Copy link
Member

Choose a reason for hiding this comment

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

Convert to BackendMessageCode?

@NinoFloris NinoFloris mentioned this pull request Aug 15, 2023
8 tasks
@NinoFloris NinoFloris modified the milestones: 6.0.11, 8.0.0 Sep 25, 2023
@Brar Brar removed this from the 8.0.0 milestone Nov 21, 2023
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.

4 participants