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
This commit is contained in:
Gleb Smirnoff 2022-02-14 09:21:55 -08:00
parent abf5bff71d
commit 65572cade3

View File

@ -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);