version 1.11, 2019/02/18 21:34:54 |
version 1.12, 2019/02/18 21:55:27 |
|
|
} |
} |
|
|
/* |
/* |
* Buffer the message from sender to the receiver indicating that the |
* Sent from the sender to the receiver to indicate that the block set |
* block set has been received. |
* has been received. |
* Symmetrises blk_send_ack(). |
* Symmetrises blk_send_ack(). |
|
* Returns zero on failure, non-zero on success. |
*/ |
*/ |
void |
int |
blk_recv_ack(struct sess *sess, char buf[20], |
blk_recv_ack(struct sess *sess, |
const struct blkset *blocks, int32_t idx) |
int fd, const struct blkset *blocks, int32_t idx) |
{ |
{ |
|
char buf[20]; |
size_t pos = 0, sz; |
size_t pos = 0, sz; |
|
|
sz = sizeof(int32_t) + /* index */ |
sz = sizeof(int32_t) + /* index */ |
|
|
sizeof(int32_t) + /* block length */ |
sizeof(int32_t) + /* block length */ |
sizeof(int32_t) + /* checksum length */ |
sizeof(int32_t) + /* checksum length */ |
sizeof(int32_t); /* block remainder */ |
sizeof(int32_t); /* block remainder */ |
assert(sz == 20); |
assert(sz <= sizeof(buf)); |
|
|
io_buffer_int(sess, buf, &pos, sz, idx); |
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->blksz); |
|
|
io_buffer_int(sess, buf, &pos, sz, blocks->csum); |
io_buffer_int(sess, buf, &pos, sz, blocks->csum); |
io_buffer_int(sess, buf, &pos, sz, blocks->rem); |
io_buffer_int(sess, buf, &pos, sz, blocks->rem); |
assert(pos == sz); |
assert(pos == sz); |
|
|
|
if (!io_write_buf(sess, fd, buf, sz)) { |
|
ERRX1(sess, "io_write_buf"); |
|
return 0; |
|
} |
|
|
|
return 1; |
} |
} |
|
|
/* |
/* |