diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Stop the sendfile loop at the end of a short slot
sendfile returns zero at the end of the file, and the loop only ended once the offset reached the size recorded when the slot was opened, so a slot cut shorter in between spun the request forever. Only Linux builds this path. A stand-in header type checked it here.
Diffstat (limited to 'source/cache.c')
-rw-r--r--source/cache.c4
1 file changed, 4 insertions, 0 deletions
diff --git a/source/cache.c b/source/cache.c
index 62bb623..60e071b 100644
--- a/source/cache.c
+++ b/source/cache.c
@@ -150,6 +150,10 @@ static int print_slot(struct cache_slot *slot)
break;
return errno;
}
+ // Zero means the file ended short of the size it had when it
+ // was opened, and the read loop below finds that end.
+ if (ret == 0)
+ break;
if (off == size)
return 0;
} while (1);