FreeBSD Bugzilla – Attachment 244557 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]
sockets: re-check socket state after call to pr_rcvd()
patch (text/plain), 1.69 KB, created by
Greg Becker
on 2023-09-01 13:28:04 UTC
(
hide
)
Description:
sockets: re-check socket state after call to pr_rcvd()
Filename:
MIME Type:
Creator:
Greg Becker
Created:
2023-09-01 13:28:04 UTC
Size:
1.69 KB
patch
obsolete
>From 27dcd8530dbfc5d47dee9a04e9c6f4b022527bb0 Mon Sep 17 00:00:00 2001 >From: Greg Becker <becker.greg@att.net> >Date: Fri, 1 Sep 2023 08:21:43 -0500 >Subject: 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 | 5 +++++ > 2 files changed, 7 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..0a2ac005035d 100644 >--- a/sys/kern/uipc_socket.c >+++ b/sys/kern/uipc_socket.c >@@ -2429,6 +2429,11 @@ 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 (so->so_rcv.sb_mb == NULL) { >+ if (so->so_error || so->so_rerror || >+ so->so_rcv.sb_state & SBS_CANTRCVMORE) >+ break; >+ } > } > SBLASTRECORDCHK(&so->so_rcv); > SBLASTMBUFCHK(&so->so_rcv); >-- >2.41.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