version 1.20, 2019/05/08 20:00:25 |
version 1.21, 2019/05/08 21:30:11 |
|
|
* Returns zero on failure, non-zero on success. |
* Returns zero on failure, non-zero on success. |
*/ |
*/ |
static int |
static int |
buf_copy(struct sess *sess, |
buf_copy(const char *buf, size_t sz, struct download *p) |
const char *buf, size_t sz, struct download *p) |
|
{ |
{ |
size_t rem, tocopy; |
size_t rem, tocopy; |
ssize_t ssz; |
ssize_t ssz; |
|
|
|
|
/* Create the temporary file. */ |
/* Create the temporary file. */ |
|
|
if (mktemplate(sess, &p->fname, |
if (mktemplate(&p->fname, f->path, sess->opts->recursive) == |
f->path, sess->opts->recursive) == -1) { |
-1) { |
ERRX1("mktemplate"); |
ERRX1("mktemplate"); |
goto out; |
goto out; |
} |
} |
|
|
if (!io_read_buf(sess, p->fdin, buf, sz)) { |
if (!io_read_buf(sess, p->fdin, buf, sz)) { |
ERRX1("io_read_int"); |
ERRX1("io_read_int"); |
goto out; |
goto out; |
} else if (!buf_copy(sess, buf, sz, p)) { |
} else if (!buf_copy(buf, sz, p)) { |
ERRX1("buf_copy"); |
ERRX1("buf_copy"); |
goto out; |
goto out; |
} |
} |
|
|
|
|
/* Fast-track more reads as they arrive. */ |
/* Fast-track more reads as they arrive. */ |
|
|
if ((c = io_read_check(sess, p->fdin)) < 0) { |
if ((c = io_read_check(p->fdin)) < 0) { |
ERRX1("io_read_check"); |
ERRX1("io_read_check"); |
goto out; |
goto out; |
} else if (c > 0) |
} else if (c > 0) |
|
|
*/ |
*/ |
|
|
assert(p->map != MAP_FAILED); |
assert(p->map != MAP_FAILED); |
if (!buf_copy(sess, buf, sz, p)) { |
if (!buf_copy(buf, sz, p)) { |
ERRX1("buf_copy"); |
ERRX1("buf_copy"); |
goto out; |
goto out; |
} |
} |
|
|
|
|
/* Fast-track more reads as they arrive. */ |
/* Fast-track more reads as they arrive. */ |
|
|
if ((c = io_read_check(sess, p->fdin)) < 0) { |
if ((c = io_read_check(p->fdin)) < 0) { |
ERRX1("io_read_check"); |
ERRX1("io_read_check"); |
goto out; |
goto out; |
} else if (c > 0) |
} else if (c > 0) |
|
|
return 1; |
return 1; |
} |
} |
|
|
if (!buf_copy(sess, NULL, 0, p)) { |
if (!buf_copy(NULL, 0, p)) { |
ERRX1("buf_copy"); |
ERRX1("buf_copy"); |
goto out; |
goto out; |
} |
} |