summaryrefslogtreecommitdiff
path: root/usr.bin/rsync/blocks.c
diff options
context:
space:
mode:
authorSebastian Benoit <benno@cvs.openbsd.org>2019-02-18 21:34:55 +0000
committerSebastian Benoit <benno@cvs.openbsd.org>2019-02-18 21:34:55 +0000
commitbde034a382776f3c396eef446206fe579292673e (patch)
treecc19160b5f11f9dcb25f390e1b1f89f36bb5b3f2 /usr.bin/rsync/blocks.c
parent574102a6ff9a74c28f2f7825a5f76cbd68781424 (diff)
sync with kristaps up to Sun Feb 17 2019
339cf5998c0c022623cd68de50722b6c14543952 Push "error trail" further into code. baf58ce5fe1bc6ce431b3b0ac8264b83ae8c7d02 Document all arguments. Add common -av usage. Remove bits about not supporting anything but files/dirs. 821a811a8c80e52fb56b241fc65a16cae1b4fb2c Disambiguate as prodded by deraadt@ 6c4475b8f226e9031ec0ec1b3f14f7d347132c87 Add -h to usage string 4d344ae6156873b44c95de0c1ed629e637c2d7ab Clarify error message language, use service name instead of port, specify that the socket is SOCK_STREAM. From deraadt@. Tweaked for lowercase messages. f3ec049e76257fc96bcdc872f1d3b967b98f3eb6 In consideration to benno@'s comments, let the mktemp functions propogate an errno handled by the caller. Also keep the original line lengths. While in mktemp.c, make some defines into an enum. e116c2bd00e634b56e4276120135915ceaa31cf2 Put the FSM of the sender into its own function. Put dry_run ack and end of phase ack into the send buffer too, further reducing the possibility of deadlock. c7745aa4c7394ca89d841f8ee76782256d694340 Make the sender write loop be fully non-blocking. This frees us of deadlocking the protocol because the sender will always be able to pull down data. 93c7b4843e80aeac2ec6ae6ffc395df4deaf4a31 Remove "yoda" notation to be more in tune with OpenBSD. Most found by deraadt@.
Diffstat (limited to 'usr.bin/rsync/blocks.c')
-rw-r--r--usr.bin/rsync/blocks.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/usr.bin/rsync/blocks.c b/usr.bin/rsync/blocks.c
index bdd880fc11c..a65ea84da69 100644
--- a/usr.bin/rsync/blocks.c
+++ b/usr.bin/rsync/blocks.c
@@ -1,4 +1,4 @@
-/* $Id: blocks.c,v 1.10 2019/02/17 16:34:04 deraadt Exp $ */
+/* $Id: blocks.c,v 1.11 2019/02/18 21:34:54 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -201,16 +201,14 @@ blk_match(struct sess *sess, const struct blkset *blks,
}
/*
- * Sent from the sender to the receiver to indicate that the block set
- * has been received.
+ * Buffer the message from sender to the receiver indicating that the
+ * block set has been received.
* Symmetrises blk_send_ack().
- * Returns zero on failure, non-zero on success.
*/
-int
-blk_recv_ack(struct sess *sess,
- int fd, const struct blkset *blocks, int32_t idx)
+void
+blk_recv_ack(struct sess *sess, char buf[20],
+ const struct blkset *blocks, int32_t idx)
{
- char buf[20];
size_t pos = 0, sz;
sz = sizeof(int32_t) + /* index */
@@ -218,7 +216,7 @@ blk_recv_ack(struct sess *sess,
sizeof(int32_t) + /* block length */
sizeof(int32_t) + /* checksum length */
sizeof(int32_t); /* block remainder */
- assert(sz <= sizeof(buf));
+ assert(sz == 20);
io_buffer_int(sess, buf, &pos, sz, idx);
io_buffer_int(sess, buf, &pos, sz, blocks->blksz);
@@ -226,13 +224,6 @@ blk_recv_ack(struct sess *sess,
io_buffer_int(sess, buf, &pos, sz, blocks->csum);
io_buffer_int(sess, buf, &pos, sz, blocks->rem);
assert(pos == sz);
-
- if (!io_write_buf(sess, fd, buf, sz)) {
- ERRX1(sess, "io_write_buf");
- return 0;
- }
-
- return 1;
}
/*