Date: Mon, 14 Feb 2022 17:23:02 GMT From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 65572cade35a - main - unix/dgram: return EAGAIN instead of ENOBUFS when O_NONBLOCK set Message-ID: <202202141723.21EHN2a0047018@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=65572cade35a93add2168a7a012f808ac499218b commit 65572cade35a93add2168a7a012f808ac499218b Author: Gleb Smirnoff <glebius@FreeBSD.org> AuthorDate: 2022-02-14 17:21:55 +0000 Commit: Gleb Smirnoff <glebius@FreeBSD.org> CommitDate: 2022-02-14 17:21:55 +0000 unix/dgram: return EAGAIN instead of ENOBUFS when O_NONBLOCK set This is behavior what some programs expect and what Linux does. For example nginx expects EAGAIN when sending messages to /var/run/log, which it connects to with O_NONBLOCK. Particularly with nginx the problem is magnified by the fact that a ENOBUFS on send(2) is also logged, so situation creates a log-bomb - a failed log message triggers another log message. Reviewed by: markj Differential revision: https://reviews.freebsd.org/D34187 --- sys/kern/uipc_usrreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 89d4198652c3..360cd5424924 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1062,7 +1062,7 @@ uipc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, control = NULL; } else { soroverflow_locked(so2); - error = ENOBUFS; + error = (so->so_state & SS_NBIO) ? EAGAIN : ENOBUFS; } if (nam != NULL) unp_disconnect(unp, unp2);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202202141723.21EHN2a0047018>