From nobody Wed Nov 13 14:16:36 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XpQM831XHz5dfHd; Wed, 13 Nov 2024 14:16:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XpQM82KT2z4nP7; Wed, 13 Nov 2024 14:16:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731507396; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=G13WxosrCURDNU40ZXSMtMJtwswk+CL2EjCof5xmy+8=; b=qpM6ZEBLbQaI78zwMNHZZdWWy2E1WZAaHrV4suvS5o34uuOgEchq9/sQgJHKgnk+KgPde3 1tfvs4oNG7aWHzIX+NiselPTbkIYyAPuxohpVj4+P2f4LDls9r4BnbWqwwsnzK26W58gfB KECcH5iOfCbBtey8bZ7JAANKG4Rj9osZrPvRv71YasWFWPNHbkFNAL0rZn/VrZSJoCLSPH AnhU0tT96n6vYD4h4ZTgPucSkcRg/YvDxUHR2tVv2awg+/foGzvM/XNBTsH0K7v6CSrrcJ GX3ZqDbZD1NqhlCjEwcclPfTRX8MQ9t5DHvs8FTgTH5EMqq+rw7dwJGHmtzlJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731507396; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=G13WxosrCURDNU40ZXSMtMJtwswk+CL2EjCof5xmy+8=; b=XeMo91F0q886nHEBEFQOjCtv1O2ZLBsFfrzARELXJtZCp0+c8Yv+8zDKsXw4z5l7Ui/uRj 6EXF3QJyzezTLWx9bOczjY8Q4o/xB7HEh9P19gjugyeeFopyPsSquO2045l+TgvXCwd/vn 1nOuM2E1hQDTpbgY15BmZpctJ8MFBsJ9QlUgIh6b0xKcIoX8IsOLa6LmsDq6EMjyxo5Fmu hn0Ch6Ru7uN5Yjrk4OjyHEe3TkttL9rf4DUnoID8vf1CeUZhlLGHQzMAyKC0ea5vSEiwrV VUFnxEa3ddjrNwPpUBl2x9uDeAJ+AJ8UHDnQN3fFHgM5egS5OOfjhQ6s3suKPw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731507396; a=rsa-sha256; cv=none; b=bJCDa/FEWDqvdK0UPUCyAFQ3iQZ9WlmgWbkkgyklnD98v6VDYPklg3VNZY73Eb0WpdJFNj rT2npqkgoDgXz4piD6u9/sGHNxBsEqUJAaULfw/HG2w3FIcTjLudIovvycei2XC6SyjLsR Ged17WsXUSR9N/TIA0T88TvU0k6n/pa5frbeqMiWcenOzZUlSPBaVsDnT/ASDss9oofL17 KBwiQUm5+fMJFHmrHhVcn2CXRBdmtm8WQKb9DCCGOP4LuiD5sqduayzXbqRCVD7d2tG5Vu qmzGx6Bj2xHIndfTlQ5p10k/pgsBKhv2ArYpWx/Mz2oCq8aukPvJFfPPLVrJEA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XpQM81wnjzy05; Wed, 13 Nov 2024 14:16:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4ADEGaDx055371; Wed, 13 Nov 2024 14:16:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4ADEGaJ4055368; Wed, 13 Nov 2024 14:16:36 GMT (envelope-from git) Date: Wed, 13 Nov 2024 14:16:36 GMT Message-Id: <202411131416.4ADEGaJ4055368@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: a43b745aaf4f - main - linux sendfile: Fix handling of non-blocking sockets List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a43b745aaf4f5bbc96875d2ab3ec9bea8024eda4 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=a43b745aaf4f5bbc96875d2ab3ec9bea8024eda4 commit a43b745aaf4f5bbc96875d2ab3ec9bea8024eda4 Author: Mark Johnston AuthorDate: 2024-11-13 14:15:47 +0000 Commit: Mark Johnston CommitDate: 2024-11-13 14:15:47 +0000 linux sendfile: Fix handling of non-blocking sockets FreeBSD sendfile() may perform a partial transfer and return EAGAIN if the socket is non-blocking. Linux sendfile() expects no error in this case, so squash EAGAIN. PR: 282495 Tested by: pieter@krikkit.xyz MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D47447 --- sys/compat/linux/linux_socket.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index 15431bf3127c..6c6751ad30a8 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -2538,6 +2538,13 @@ sendfile_sendfile(struct thread *td, struct file *fp, l_int out, current_offset = *offset; error = fo_sendfile(fp, out, NULL, NULL, current_offset, count, sbytes, 0, td); + if (error == EAGAIN && *sbytes > 0) { + /* + * The socket is non-blocking and we didn't finish sending. + * Squash the error, since that's what Linux does. + */ + error = 0; + } if (error == 0) { current_offset += *sbytes; if (offset != NULL)