Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Feb 2023 17:05:53 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: 71e70c25c008 - main - Revert "unix/dgram: return EAGAIN instead of ENOBUFS when O_NONBLOCK set"
Message-ID:  <202302211705.31LH5r2X080164@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=71e70c25c0085a4e6e5eef834ca8a29b65435d62

commit 71e70c25c0085a4e6e5eef834ca8a29b65435d62
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2023-02-21 16:50:07 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2023-02-21 16:50:07 +0000

    Revert "unix/dgram: return EAGAIN instead of ENOBUFS when O_NONBLOCK set"
    
    This API change led to unexpected consequences with Go runtime. The
    Go runtime emulates blocking sockets over non-blocking sockets and
    for that uses available event dispatcher on the target OS, which is
    kevent(2) if availabe, with OS independent layer on top.  It expects
    that if whatever O_NONBLOCK socket returned ever EAGAIN, then it is
    supposed to be reported as writable by the event dispatcher. kevent(2)
    would never report a unix/dgram socket, since they never change their
    state, they always are writeable.  The expectations of Go are not
    literally specified by SUS, however they are in its spirit.  The SUS
    specifies EAGAIN for send(2) as "The socket's file descriptor is marked
    O_NONBLOCK and the requested operation would block" [1].  This doesn't
    apply to FreeBSD unix/dgram socket, it never blocks on send(2).
    
    Thus, changing API trying to mimic Linux was a mistake.  But what about
    the problem we tried to fix? Discussed that with Max Dounin of nginx,
    and we agreed that the log bomb described shall be fixed on nginx side,
    and it actually isn't specific to FreeBSD, may happen with nginx on any
    non-Linux system with a certain configuration.
    
    [1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/send.html
    
    This reverts commit 65572cade35a93add2168a7a012f808ac499218b.
---
 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 8f86bdb48c69..294ef807416c 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -1338,7 +1338,7 @@ uipc_sosend_dgram(struct socket *so, struct sockaddr *addr, struct uio *uio,
 		f = NULL;
 	} else {
 		soroverflow_locked(so2);
-		error = (so->so_state & SS_NBIO) ? EAGAIN : ENOBUFS;
+		error = ENOBUFS;
 		if (f->m_next->m_type == MT_CONTROL)
 			unp_scan(f->m_next, unp_freerights);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202302211705.31LH5r2X080164>