FreeBSD Bugzilla – Attachment 244732 Details for
Bug 212716
recv() with MSG_WAITALL doesn't always unblock on EOF
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
ockets: re-check socket state after call to pr_rcvd()
0002-sockets-re-check-socket-state-after-call-to-pr_rcvd.patch (text/plain), 1.71 KB, created by
Greg Becker
on 2023-09-09 13:33:25 UTC
(
hide
)
Description:
ockets: re-check socket state after call to pr_rcvd()
Filename:
MIME Type:
Creator:
Greg Becker
Created:
2023-09-09 13:33:25 UTC
Size:
1.71 KB
patch
obsolete
>From 44d2f9daf6e10046d2702aa60059744974728aa9 Mon Sep 17 00:00:00 2001 >From: Greg Becker <becker.greg@att.net> >Date: Sat, 9 Sep 2023 06:24:20 -0500 >Subject: [PATCH 2/2] sockets: re-check socket state after call to pr_rcvd() > >Socket state may have changed after dropping the receive >buffer lock in order to call pr_rcvd(). If the buffer is >empty, re-check the state after reaquiring the lock and >skip calling sbwait() if the socket is in error or the >peer has closed. >--- > sys/kern/uipc_sockbuf.c | 2 ++ > sys/kern/uipc_socket.c | 4 ++++ > 2 files changed, 6 insertions(+) > >diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c >index e76f198f42dc..14851bdb2be8 100644 >--- a/sys/kern/uipc_sockbuf.c >+++ b/sys/kern/uipc_sockbuf.c >@@ -456,6 +456,8 @@ sbwait(struct socket *so, sb_which which) > SOCK_BUF_LOCK_ASSERT(so, which); > > sb = sobuf(so, which); >+ KASSERT((sb->sb_state & (SBS_CANTRCVMORE | SBS_CANTSENDMORE)) == 0, >+ ("sbwait: %s", (which == SO_RCV) ? "CANTRCVMORE" : "CANTSENDMORE")); > sb->sb_flags |= SB_WAIT; > return (msleep_sbt(&sb->sb_acc, soeventmtx(so, which), > (sb->sb_flags & SB_NOINTR) ? PSOCK : PSOCK | PCATCH, "sbwait", >diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c >index ffd5e06c34b7..3c7e5c4cb4bb 100644 >--- a/sys/kern/uipc_socket.c >+++ b/sys/kern/uipc_socket.c >@@ -2429,6 +2429,10 @@ soreceive_generic(struct socket *so, struct sockaddr **psa, struct uio *uio, > VNET_SO_ASSERT(so); > pr->pr_rcvd(so, flags); > SOCKBUF_LOCK(&so->so_rcv); >+ if (__predict_false(so->so_rcv.sb_mb == NULL && >+ (so->so_error || so->so_rerror || >+ so->so_rcv.sb_state & SBS_CANTRCVMORE))) >+ break; > } > SBLASTRECORDCHK(&so->so_rcv); > SBLASTMBUFCHK(&so->so_rcv); >-- >2.42.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 212716
:
244510
|
244523
|
244533
|
244557
| 244732