reftable: handle interrupted reads
There are calls to pread(3P) and read(3P) where we don't properly handle interrupts. Convert them to use `pread_in_full()` and `read_in_full()`, respectively. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
e32b8ece64
commit
917a2b3ce9
@ -109,7 +109,7 @@ static int file_read_block(void *v, struct reftable_block *dest, uint64_t off,
|
|||||||
struct file_block_source *b = v;
|
struct file_block_source *b = v;
|
||||||
assert(off + size <= b->size);
|
assert(off + size <= b->size);
|
||||||
dest->data = reftable_malloc(size);
|
dest->data = reftable_malloc(size);
|
||||||
if (pread(b->fd, dest->data, size, off) != size)
|
if (pread_in_full(b->fd, dest->data, size, off) != size)
|
||||||
return -1;
|
return -1;
|
||||||
dest->len = size;
|
dest->len = size;
|
||||||
return size;
|
return size;
|
||||||
|
@ -92,7 +92,7 @@ static int fd_read_lines(int fd, char ***namesp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf = reftable_malloc(size + 1);
|
buf = reftable_malloc(size + 1);
|
||||||
if (read(fd, buf, size) != size) {
|
if (read_in_full(fd, buf, size) != size) {
|
||||||
err = REFTABLE_IO_ERROR;
|
err = REFTABLE_IO_ERROR;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user