From 5bdf8150cd7d19b0bd672992e6f964d30ce66408 Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Thu, 1 Feb 2024 13:37:26 -0800 Subject: [PATCH] unix/dgram: don't clear so_error in case of MSG_PEEK --- sys/kern/uipc_usrreq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 554099586bb..976490dbe2d 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1440,7 +1440,8 @@ uipc_soreceive_dgram(struct socket *so, struct sockaddr **psa, struct uio *uio, (m = STAILQ_FIRST(&so->so_rcv.uxdg_mb)) == NULL) { if (so->so_error) { error = so->so_error; - so->so_error = 0; + if (!(flags & MSG_PEEK)) + so->so_error = 0; SOCK_RECVBUF_UNLOCK(so); SOCK_IO_RECV_UNLOCK(so); return (error);