version 1.11, 2019/02/16 10:47:20 |
version 1.12, 2019/02/16 16:55:35 |
|
|
int |
int |
rsync_downloader(struct download *p, struct sess *sess, int *ofd) |
rsync_downloader(struct download *p, struct sess *sess, int *ofd) |
{ |
{ |
|
int c; |
int32_t idx, rawtok; |
int32_t idx, rawtok; |
const struct flist *f; |
const struct flist *f; |
size_t sz, tok; |
size_t sz, tok; |
|
|
* a token indicator. |
* a token indicator. |
*/ |
*/ |
|
|
|
again: |
assert(p->state == DOWNLOAD_READ_REMOTE); |
assert(p->state == DOWNLOAD_READ_REMOTE); |
assert(p->fname != NULL); |
assert(p->fname != NULL); |
assert(p->fd != -1); |
assert(p->fd != -1); |
|
|
LOG4(sess, "%s: received %zu B block", p->fname, sz); |
LOG4(sess, "%s: received %zu B block", p->fname, sz); |
MD4_Update(&p->ctx, buf, sz); |
MD4_Update(&p->ctx, buf, sz); |
free(buf); |
free(buf); |
|
|
|
/* Fast-track more reads as they arrive. */ |
|
|
|
if ((c = io_read_check(sess, p->fdin)) < 0) { |
|
ERRX1(sess, "io_read_check"); |
|
goto out; |
|
} else if (c > 0) |
|
goto again; |
|
|
return 1; |
return 1; |
} else if (rawtok < 0) { |
} else if (rawtok < 0) { |
tok = -rawtok - 1; |
tok = -rawtok - 1; |
|
|
p->total += sz; |
p->total += sz; |
LOG4(sess, "%s: copied %zu B", p->fname, sz); |
LOG4(sess, "%s: copied %zu B", p->fname, sz); |
MD4_Update(&p->ctx, buf, sz); |
MD4_Update(&p->ctx, buf, sz); |
|
|
|
/* Fast-track more reads as they arrive. */ |
|
|
|
if ((c = io_read_check(sess, p->fdin)) < 0) { |
|
ERRX1(sess, "io_read_check"); |
|
goto out; |
|
} else if (c > 0) |
|
goto again; |
|
|
return 1; |
return 1; |
} |
} |
|
|