[lttng-dev] [PATCH] Fix: handle EINTR return value for bt_posix_fallocate

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Tue Oct 13 16:04:23 EDT 2015


Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
 formats/ctf/ctf.c             | 9 +++++----
 formats/ctf/ir/event-fields.c | 8 ++++++--
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c
index 8236b6e..757fa85 100644
--- a/formats/ctf/ctf.c
+++ b/formats/ctf/ctf.c
@@ -861,7 +861,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) {
@@ -905,9 +904,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/ir/event-fields.c b/formats/ctf/ir/event-fields.c
index aa7475d..3358ff0 100644
--- a/formats/ctf/ir/event-fields.c
+++ b/formats/ctf/ir/event-fields.c
@@ -2171,9 +2171,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.1.4




More information about the lttng-dev mailing list