The branch main has been updated by glebius:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=65572cade35a93add2168a7a012f808ac499218b

commit 65572cade35a93add2168a7a012f808ac499218b
Author:     Gleb Smirnoff <[email protected]>
AuthorDate: 2022-02-14 17:21:55 +0000
Commit:     Gleb Smirnoff <[email protected]>
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);

Reply via email to