From 118f5776fcc9e4dc1e79d96d697825bc95174fcb Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 13 Oct 2015 16:04:23 -0400 Subject: [PATCH] Fix: handle EINTR return value for bt_posix_fallocate MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- formats/ctf/ctf.c | 9 +++++---- formats/ctf/writer/event-fields.c | 8 ++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index fb4ef730..9cb19f4d 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -863,7 +863,6 @@ void ctf_packet_seek(struct bt_stream_pos *stream_pos, size_t index, int whence) struct ctf_file_stream *file_stream = container_of(pos, struct ctf_file_stream, pos); int ret; - off_t off; struct packet_index *packet_index, *prev_index; switch (whence) { @@ -907,9 +906,11 @@ void ctf_packet_seek(struct bt_stream_pos *stream_pos, size_t index, int whence) } pos->content_size = -1U; /* Unknown at this point */ pos->packet_size = WRITE_PACKET_LEN; - off = bt_posix_fallocate(pos->fd, pos->mmap_offset, - pos->packet_size / CHAR_BIT); - assert(off == 0); + do { + ret = bt_posix_fallocate(pos->fd, pos->mmap_offset, + pos->packet_size / CHAR_BIT); + } while (ret == EINTR); + assert(ret == 0); pos->offset = 0; } else { read_next_packet: diff --git a/formats/ctf/writer/event-fields.c b/formats/ctf/writer/event-fields.c index 9eff2dca..c49bc3fa 100644 --- a/formats/ctf/writer/event-fields.c +++ b/formats/ctf/writer/event-fields.c @@ -1242,9 +1242,13 @@ int increase_packet_size(struct ctf_stream_pos *pos) } pos->packet_size += PACKET_LEN_INCREMENT; - ret = bt_posix_fallocate(pos->fd, pos->mmap_offset, - pos->packet_size / CHAR_BIT); + do { + ret = bt_posix_fallocate(pos->fd, pos->mmap_offset, + pos->packet_size / CHAR_BIT); + } while (ret == EINTR); if (ret) { + errno = EINTR; + ret = -1; goto end; } -- 2.34.1