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

TestSocket_UNIXSocket: stop testing empty packets #8338

Merged
merged 1 commit into from
Aug 31, 2023

Conversation

casperisfine
Copy link
Contributor

Followup: #6407
[Bug #19012]

OpenBSD and Solaris behave differently here.

Linux does deliver the empty packet, which is questionable as it's undistinguishable from a closed connection.

It seems that OpenBSD and Solaris simply drop it.

We could test the platform before doing the assertion, but it would likely be fragile, and the entire web recommend to not ever send an empty packet, so the value of this assertion is low.

OpenBSD and Solaris behave differently here.

Linux does deliver the empty packet, which is questionable
as it's undistinguishable from a closed connection.

It seems that OpenBSD and Solaris simply drop it.

We could test the platform before doing the assertion, but
it would likely be fragile, and the entire web recommend
to not ever send an empty packet, so the value of this
assertion is low.
@ioquatix
Copy link
Member

ioquatix commented Aug 31, 2023

Linux does deliver the empty packet, which is questionable as it's undistinguishable from a closed connection.

What's the actual semantics? readmsg returns 0?

@casperisfine
Copy link
Contributor Author

readmsg returns 0?

Yhe issue is with recvmsg, but essentially yes https://linux.die.net/man/2/recvmsg

Return Value
These calls return the number of bytes received, or -1 if an error occurred. The return value will be 0 when the peer has performed an orderly shutdown.

So if you received a 0B packet, it returns 0. If the peer did shutdown the connection, it also returns 0.

There is no way to differentiate the two cases as far as I'm aware. Most discussions on this topic I was able to see basically concluded with: "Don't send empty packets".

@byroot byroot merged commit 0270210 into ruby:master Aug 31, 2023
93 checks passed
@ioquatix
Copy link
Member

Yhe issue is with recvmsg

Thanks for the correction, sorry I was half asleep :)

basically concluded with: "Don't send empty packets".

Makes sense. I wonder if we can get around that by using something like wait_readable... a closed connection will return different from a connection that's still open IIRC.

@XrXr XrXr deleted the remove-empty-sock-seqpacket-assertion branch September 28, 2023 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants