Skip to content

Commit 85a8c89

Browse files
pks-tgitster
authored andcommitted
reftable: handle interrupted writes
There are calls to write(3P) where we don't properly handle interrupts. Convert them to use `write_in_full()`. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 917a2b3 commit 85a8c89

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

reftable/stack.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static void stack_filename(struct strbuf *dest, struct reftable_stack *st,
4242
static ssize_t reftable_fd_write(void *arg, const void *data, size_t sz)
4343
{
4444
int *fdp = (int *)arg;
45-
return write(*fdp, data, sz);
45+
return write_in_full(*fdp, data, sz);
4646
}
4747

4848
int reftable_new_stack(struct reftable_stack **dest, const char *dir,
@@ -554,7 +554,7 @@ int reftable_addition_commit(struct reftable_addition *add)
554554
strbuf_addstr(&table_list, "\n");
555555
}
556556

557-
err = write(add->lock_file_fd, table_list.buf, table_list.len);
557+
err = write_in_full(add->lock_file_fd, table_list.buf, table_list.len);
558558
strbuf_release(&table_list);
559559
if (err < 0) {
560560
err = REFTABLE_IO_ERROR;
@@ -1024,7 +1024,7 @@ static int stack_compact_range(struct reftable_stack *st, int first, int last,
10241024
strbuf_addstr(&ref_list_contents, "\n");
10251025
}
10261026

1027-
err = write(lock_file_fd, ref_list_contents.buf, ref_list_contents.len);
1027+
err = write_in_full(lock_file_fd, ref_list_contents.buf, ref_list_contents.len);
10281028
if (err < 0) {
10291029
err = REFTABLE_IO_ERROR;
10301030
unlink(new_table_path.buf);

reftable/stack_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static void test_read_file(void)
7878
int i = 0;
7979

8080
EXPECT(fd > 0);
81-
n = write(fd, out, strlen(out));
81+
n = write_in_full(fd, out, strlen(out));
8282
EXPECT(n == strlen(out));
8383
err = close(fd);
8484
EXPECT(err >= 0);

0 commit comments

Comments
 (0)