Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Sep 2014 09:57:57 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r271582 - projects/sendfile/sys/kern
Message-ID:  <201409140957.s8E9vvW7010959@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;
+		}
 	}
 
 	/*



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