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

ensuring to receive 4 bytes. #991

Merged
merged 3 commits into from
May 23, 2024
Merged

Conversation

kazu-yamamoto
Copy link
Contributor

Fix #989.

@mitchellwrosen Would you review this PR?

@mitchellwrosen
Copy link
Contributor

Looks good!

@Vlix
Copy link
Contributor

Vlix commented May 21, 2024

As long as connRecv always gets an amount of bytes > 0, this should be fine.
If it can produce 0 bytes, then this loop might be infinite (would that result in a timeout?)

What if only 3 bytes were sent?


And the L389 bs0 <- recv4 could be replaced with:

bs0 <- connRecv conn >>= loop

So you don't need the recv4 function.

@kazu-yamamoto
Copy link
Contributor Author

kazu-yamamoto commented May 22, 2024

@Vlix I fixed the infinity loop. Please check it again.

@Vlix
Copy link
Contributor

Vlix commented May 22, 2024

I'd use S.null bs1 to check for empty ByteString, but it looks fine 👍

Also, when doing <> on ByteStrings where one is empty, it just drops it, so it's pretty much as close to efficient as can be. 👍

Using a literal "" will do some unnecessary memory allocation though, it seems, so using S.empty would be more efficient (will just be a static nullForeignPtr which will be dropped at the first <>)

@kazu-yamamoto
Copy link
Contributor Author

During modification, len is used twice.
But in the current code, I agree that null is better.

@Vlix Vlix self-requested a review May 23, 2024 00:47
@kazu-yamamoto kazu-yamamoto merged commit 85ad932 into yesodweb:master May 23, 2024
0 of 18 checks passed
@kazu-yamamoto kazu-yamamoto deleted the recv4 branch May 23, 2024 01:10
@kazu-yamamoto
Copy link
Contributor Author

Merged.
Thank you for reviewing!

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.

"is http2" detection doesn't seem quite correct
3 participants