Page MenuHomeFreeBSD

Support MSG_DONTWAIT in sendmsg()
ClosedPublic

Authored by val_packett.cool on Jan 3 2019, 4:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 7, 11:29 PM
Unknown Object (File)
Feb 24 2024, 2:20 AM
Unknown Object (File)
Jan 15 2024, 3:44 AM
Unknown Object (File)
Dec 22 2023, 10:32 PM
Unknown Object (File)
Dec 18 2023, 1:06 PM
Unknown Object (File)
Oct 24 2023, 2:12 AM
Unknown Object (File)
Oct 19 2023, 8:47 PM
Unknown Object (File)
Oct 19 2023, 6:56 PM

Details

Summary

Sometimes Weston (or any Wayland compositor really) would become unresponsive (whole UI frozen, mouse doesn't move) when a client (desktop app) became unresponsive. After some testing with procstat, the cause was found: sendmsg. Turns out libwayland-server was telling the kernel to not block on sendmsg, but the kernel wasn't listening.

https://gitlab.freedesktop.org/wayland/wayland/blob/921d0548035673a1bf6aeb9396b9bc728133411e/src/connection.c#L314-317

sendmsg(connection->fd, &msg, MSG_NOSIGNAL | MSG_DONTWAIT);

As a workaround MSG_NBIO can be used, but according to the comment it's intended for some fifo stuff. Let's support the correct constant that other operating systems support, e.g. OpenBSD does support it.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

markj added subscribers: tuexen, markj.

This seems fine to me. sdp_sosend() needs the same treatment. sctp_sosend() probably does as well, but I don't see where. @tuexen might know.

sys/kern/uipc_socket.c
1525

You can test both flags at once: (flags & (MSG_DONTWAIT | MSG_NBIO)) != 0

This revision is now accepted and ready to land.Jan 3 2019, 4:44 PM
bcr added a subscriber: bcr.

OK from manpages, too.

sys/kern/uipc_socket.c
1525

oh, right, with !=0 it won't be a check for both, thanks for the tip

I think that's the right place in sctp. I'm not sure how to test it though, or the sdp thing…

This revision now requires review to proceed.Jan 3 2019, 6:07 PM
In D18728#399576, @greg_unrelenting.technology wrote:

I think that's the right place in sctp. I'm not sure how to test it though, or the sdp thing…

Thanks. Let's give @tuexen a day or two to weigh in on the SCTP side. sdp_sosend() is quite similar to sosend_generic(); I think it's fine to skip testing there.

sys/kern/uipc_socket.c
1525

The parens around the second condition are redundant, and the line is longer than 80 columns. I'd write

if ((so->so_state & SS_NBIO) != 0 ||
    (flags & (MSG_DONTWAIT | MSG_NBIO)) != 0) {
...
sys/netinet/sctp_output.c
12839

Redundant parens.

sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c
1127

Ditto.

val_packett.cool marked 3 inline comments as done.
val_packett.cool added a reviewer: tuexen.

Updated style.

BTW, would be nice to see this MFC'd into 12

This revision is now accepted and ready to land.Jan 3 2019, 11:48 PM
This revision was automatically updated to reflect the committed changes.