From owner-svn-src-projects@FreeBSD.ORG Sun Sep 14 09:57:57 2014 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E45DECEE; Sun, 14 Sep 2014 09:57:57 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CFB2BEE8; Sun, 14 Sep 2014 09:57:57 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s8E9vvSl010960; Sun, 14 Sep 2014 09:57:57 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s8E9vvW7010959; Sun, 14 Sep 2014 09:57:57 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201409140957.s8E9vvW7010959@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Sun, 14 Sep 2014 09:57:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r271582 - projects/sendfile/sys/kern X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Sep 2014 09:57:58 -0000 Author: glebius Date: Sun Sep 14 09:57:57 2014 New Revision: 271582 URL: http://svnweb.freebsd.org/changeset/base/271582 Log: Provide code path for soft errors. These are cases when sendfile() was able to send some data, but not to the end. According to documentation these are EAGAIN and EBUSY, Fix sf_buf_alloc() failure to EAGAIN. ENOBUFS is more meaningful, but, alas, we need to follow the historic API. Sponsored by: Netflix Sponsored by: Nginx, Inc. Modified: projects/sendfile/sys/kern/uipc_syscalls.c Modified: projects/sendfile/sys/kern/uipc_syscalls.c ============================================================================== --- projects/sendfile/sys/kern/uipc_syscalls.c Sun Sep 14 09:56:29 2014 (r271581) +++ projects/sendfile/sys/kern/uipc_syscalls.c Sun Sep 14 09:57:57 2014 (r271582) @@ -2932,12 +2932,13 @@ vn_sendfile(struct file *fp, int sockfd, struct shmfd *shmfd; struct vattr va; off_t off, sbytes, rem, obj_size; - int error, bsize, hdrlen; + int error, softerr, bsize, hdrlen; obj = NULL; so = NULL; m = mh = NULL; sbytes = 0; + softerr = 0; error = sendfile_getobj(td, fp, &obj, &vp, &shmfd, &obj_size, &bsize); if (error != 0) @@ -3132,7 +3133,7 @@ retry_space: vm_page_unlock(pa[j]); } if (m == NULL) - error = ENOBUFS; + softerr = EAGAIN; fixspace(npages, i, off, &space); break; } @@ -3198,7 +3199,7 @@ retry_space: mh = NULL; } - if (error) { + if (m == NULL) { free(sfio, M_TEMP); goto done; } @@ -3229,6 +3230,10 @@ retry_space: sbytes += space + hdrlen; if (hdrlen) hdrlen = 0; + if (softerr) { + error = softerr; + goto done; + } } /*