summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Ames <gregames@apache.org>2002-05-17 18:01:14 +0000
committerGreg Ames <gregames@apache.org>2002-05-17 18:01:14 +0000
commitc5c28635742e030406c58702993c249471a2f840 (patch)
tree9d8522145c89c81a9133db37d99730ff084bc4fd
parent8ec0e3dab9e3bf4d198411a871c63383a59799ba (diff)
downloadapr-c5c28635742e030406c58702993c249471a2f840.tar.gz
linux sendfile: exit with an error if the file gets smaller in the middle of
a request. With this patch, a faked up shrinking file, and LogLevel info, the log contains: [Fri May 17 13:34:45 2002] [info] (20514)End of file found: core_output_filter: writing data to the network ...and the assert in sendfile_it_all doesn't hit. Is APR_EOF appropriate? beats me; it gets the job done. If you think of something better, please speak up soon because I plan on doing FreeBSD next. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@63408 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--network_io/unix/sendrecv.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/network_io/unix/sendrecv.c b/network_io/unix/sendrecv.c
index f9229c8fe..da54464d4 100644
--- a/network_io/unix/sendrecv.c
+++ b/network_io/unix/sendrecv.c
@@ -390,16 +390,28 @@ do_select:
nbytes += rv;
- /* If this was a partial write, return now with the partial byte count;
- * this is a non-blocking socket.
- */
-
if (rv < *len) {
*len = nbytes;
- if (sock->timeout) {
- sock->netmask |= APR_INCOMPLETE_WRITE;
+ arv = apr_setsocketopt(sock, APR_TCP_NOPUSH, 0);
+ if (rv > 0) {
+
+ /* If this was a partial write, return now with the
+ * partial byte count; this is a non-blocking socket.
+ */
+
+ if (sock->timeout) {
+ sock->netmask |= APR_INCOMPLETE_WRITE;
+ }
+ return arv;
+ }
+ else {
+ /* If the file got smaller mid-request, eventually the offset
+ * becomes equal to the new file size and the kernel returns 0.
+ * Make this an error so the caller knows to log something and
+ * exit.
+ */
+ return APR_EOF;
}
- return apr_setsocketopt(sock, APR_TCP_NOPUSH, 0);
}
/* Now write the footers */