diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2019-02-16 16:57:49 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2019-02-16 16:57:49 +0000 |
commit | a1c653776eca5d7f38c422cbc0b8ca2f6a772753 (patch) | |
tree | 68fda8465c4277e96bf2fbdb039292e5e1c98d8f /usr.bin/rsync | |
parent | 3c8783a197d685ee5a9ffc49f21f88979650983d (diff) |
sync with kristaps, commit d7c4fb8ac88845aa08900d5d0ec469257f63a339
Use a static single block instead of multiple writes.
Diffstat (limited to 'usr.bin/rsync')
-rw-r--r-- | usr.bin/rsync/blocks.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/usr.bin/rsync/blocks.c b/usr.bin/rsync/blocks.c index b9c42ed944e..2849945d9c0 100644 --- a/usr.bin/rsync/blocks.c +++ b/usr.bin/rsync/blocks.c @@ -1,4 +1,4 @@ -/* $Id: blocks.c,v 1.7 2019/02/16 16:57:17 florian Exp $ */ +/* $Id: blocks.c,v 1.8 2019/02/16 16:57:48 florian Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -288,23 +288,29 @@ int blk_recv_ack(struct sess *sess, int fd, const struct blkset *blocks, int32_t idx) { + char buf[20]; + size_t pos = 0, sz; - /* FIXME: put into static block. */ + sz = sizeof(int32_t) + /* index */ + sizeof(int32_t) + /* block count */ + sizeof(int32_t) + /* block length */ + sizeof(int32_t) + /* checksum length */ + sizeof(int32_t); /* block remainder */ + assert(sz <= sizeof(buf)); - if (!io_write_int(sess, fd, idx)) - ERRX1(sess, "io_write_int"); - else if (!io_write_int(sess, fd, blocks->blksz)) - ERRX1(sess, "io_write_int"); - else if (!io_write_int(sess, fd, blocks->len)) - ERRX1(sess, "io_write_int"); - else if (!io_write_int(sess, fd, blocks->csum)) - ERRX1(sess, "io_write_int"); - else if (!io_write_int(sess, fd, blocks->rem)) - ERRX1(sess, "io_write_int"); - else - return 1; + io_buffer_int(sess, buf, &pos, sz, idx); + io_buffer_int(sess, buf, &pos, sz, blocks->blksz); + io_buffer_int(sess, buf, &pos, sz, blocks->len); + io_buffer_int(sess, buf, &pos, sz, blocks->csum); + io_buffer_int(sess, buf, &pos, sz, blocks->rem); + assert(pos == sz); - return 0; + if (!io_write_buf(sess, fd, buf, sz)) { + ERRX1(sess, "io_write_buf"); + return 0; + } + + return 1; } /* |