git: 4f9fac78d4da - main - linux(4): Return EAGAIN instead of ENOBUFS for non-blocking sockets in sendfile

From: Dmitry Chagin <dchagin_at_FreeBSD.org>
Date: Sat, 19 Aug 2023 18:56:17 UTC
The branch main has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=4f9fac78d4da662d4ae29c4e1d71c66cd29fcfbb

commit 4f9fac78d4da662d4ae29c4e1d71c66cd29fcfbb
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-08-19 18:55:23 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-08-19 18:55:23 +0000

    linux(4): Return EAGAIN instead of ENOBUFS for non-blocking sockets in sendfile
    
    MFC after:              1 month
---
 sys/compat/linux/linux_socket.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
index 67736ecc69f6..834c2c938925 100644
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -2570,6 +2570,8 @@ linux_sendfile_common(struct thread *td, l_int out, l_int in,
 		else
 			error = sendfile_fallback(td, fp, out, offset, count,
 			    &sbytes);
+		if (error == ENOBUFS && (ofp->f_flag & FNONBLOCK) != 0)
+			error = EAGAIN;
 		if (error == 0)
 			td->td_retval[0] = sbytes;
 	}