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
Possible typo in examples (LWS_PRE bytes padding after buffer end) #2629
Comments
It's a bit hard to understand what you're describing without a diff or links to the lines, but the http-server-dynamic cb buffer looks like this
That is we can write starting from LWS_PRE bytes inside the buffer, and we have 2048 bytes there we can use, starting at You should note well that with a 16-byte LWS_PRE, sizeof(buf) is going to be 2064 bytes. So between |
Must be either |
Yes the real usable space is 2048 starting at I don't think anything needs fixing here. If it still feels wrong, you can prove it by printing the pointer offsets / sizeof arithmetic numbers. |
Shift by LWS_PRE must be applied Schematically: how it must be:
And how it is now:
Which doesn't look correct. |
Mm but look closely, end is set referenced to |
This is why it should NOT be decreased by LSW_PRE. Subtraction would be needed only with Here's one more side for my explanation:
|
I got exact measures - pointers and diffs (they are per-byte pointers): Code, right after declaration: fprintf( stderr, "DEBUG: buf=%p start=%p: end=%p\n: (start - buf)=%zi: (end - buf)=%zi: (end - start)=%zi\n",
buf, start, end,
start - buf, end - buf, end - start); Output:
|
Oh... I think you are right... end needs to be the end. Thanks for showing it clearly. |
Some other examples are correct. I did not check all, only this one. And one, which is correct, is
|
Several examples trim their buffer with an extra LWS_PRE from the end... actually end should point to end the end of buf without a second LWS_PRE reservation. #2629
Several examples trim their buffer with an extra LWS_PRE from the end... actually end should point to end the end of buf without a second LWS_PRE reservation. #2629
Several examples trim their buffer with an extra LWS_PRE from the end... actually end should point to end the end of buf without a second LWS_PRE reservation. #2629
Several examples trim their buffer with an extra LWS_PRE from the end... actually end should point to end the end of buf without a second LWS_PRE reservation. #2629
A patch for this is on main now, thanks. |
Several examples trim their buffer with an extra LWS_PRE from the end... actually end should point to end the end of buf without a second LWS_PRE reservation. #2629
While learning earlier example about sending dynamic http, I noticed, that end of writeable area inside buffer is also padded by LWS_PRE, althoug total buffe size is
LWS_PRE + 2048
- this means, at most2048 - LWS_PRE
bytes are sent by singlelws_write()
. If such padding was required, would be more logical to name it like LWS_POST or so. My guess, end value was meaned to be likestart + sizeof(buf) - LWS_PRE - 1
or justbuf + sizeof(buf) - 1
(without-LWS_PRE
in second case).The text was updated successfully, but these errors were encountered: