Send OBJ_ITER_END only with the last chunk of data

This does not make a difference for HTTP1, and as we only use HTTP1
backends, does not many any difference right now.
parent 2580ca58
......@@ -144,7 +144,7 @@ tus_objiterator(struct worker *wrk, struct objcore *oc,
const size_t max_write = 16 * 1024 * 1024;
struct tus_concat *c;
struct tus_file_core *fcore;
unsigned i;
unsigned flags, i;
size_t off, len;
void *p;
int r = -1;
......@@ -170,20 +170,25 @@ tus_objiterator(struct worker *wrk, struct objcore *oc,
AZ(posix_madvise(p, len, POSIX_MADV_SEQUENTIAL));
AZ(posix_madvise(p, len, POSIX_MADV_WILLNEED));
off = 0;
flags = OBJ_ITER_FLUSH;
do {
len = fcore->len - off;
if (len > max_write)
len = max_write;
p = (char *)fcore->ptr + off;
r = func(priv, OBJ_ITER_END | OBJ_ITER_FLUSH, p, len);
off += len;
if (off == fcore->len)
flags |= OBJ_ITER_END;
r = func(priv, flags, p, len);
if (r < 0)
return (r);
AZ(posix_madvise(p, len, POSIX_MADV_DONTNEED));
off += len;
} while (off < fcore->len);
}
return (r);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment