Skip to contentSkip to conversation

Handle packets containing only a header

PATCH New Julien Desfossez 2 participants 3 messages Nov 27, 2013 2 messages not in the archive Library code

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 2/3 Handle packets containing only a header

In live streaming with LTTng, if we do a stop and then a destroy, we receive a packet that contains only a header. With this patch, we will ask for a new packet when we see this case.

---
 formats/ctf/ctf.c | 4 ++++
 1 file changed, 4 insertions(+)
formats/ctf/ctf.c +4 -0
index 5f263cd..5cf8097 100644
@@ -476,6 +476,10 @@ int ctf_read_event(struct bt_stream_pos *ppos, struct ctf_stream_definition *str
 		/* Stream is inactive for now (live reading). */
 		return EAGAIN;
 	}
+	/* Packet only contains headers */
+	if (pos->offset == pos->content_size)
+		return EAGAIN;
+
 	assert(pos->offset < pos->content_size);
 
 	/* Read event header */
Signature · 1 line
1.8.3.2
#2 lore raw

PATCH 3/3 Handle empty streams on iterator init

In reply to a message not in the archive

In live trace streaming, we can create an iterator with inactive streams. This patch allows inactive streams to be considered as valid.

---
 lib/iterator.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
lib/iterator.c +8 -1
index 155fcbe..3280f4a 100644
@@ -725,7 +725,7 @@ int bt_iter_init(struct bt_iter *iter,
 				if (ret == EOF) {
 					ret = 0;
 					continue;
-				} else if (ret) {
+				} else if (ret != 0 && ret != EAGAIN) {
 					goto error;
 				}
 				/* Add to heap */
@@ -821,6 +821,13 @@ reinsert:
 	removed = bt_heap_replace_max(iter->stream_heap, file_stream);
 	assert(removed == file_stream);
 
+	file_stream = bt_heap_maximum(iter->stream_heap);
+	if (file_stream->pos.content_size == 0) {
+		ret = EAGAIN;
+	} else {
+		ret = 0;
+	}
+
 end:
 	return ret;
 }
Signature · 1 line
1.8.3.2

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

Re: [BABELTRACE PATCH 3/3] Handle empty streams on iterator init

All 3 patches merged, thanks!

Mathieu

----- Original Message -----

Quoted 45 lines

From: "Julien Desfossez" <[email protected]>
To: "mathieu desnoyers" <[email protected]>
Cc: [email protected], "Julien Desfossez" <[email protected]>
Sent: Wednesday, November 27, 2013 11:40:12 AM
Subject: [BABELTRACE PATCH 3/3] Handle empty streams on iterator init

In live trace streaming, we can create an iterator with inactive streams. This patch allows inactive streams to be considered as valid.

---
 lib/iterator.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
lib/iterator.c +8 -2
index 155fcbe..3280f4a 100644
@@ -725,7 +725,7 @@ int bt_iter_init(struct bt_iter *iter,
 				if (ret == EOF) {
 					ret = 0;
 					continue;
-				} else if (ret) {
+				} else if (ret != 0 && ret != EAGAIN) {
 					goto error;
 				}
 				/* Add to heap */
@@ -821,6 +821,13 @@ reinsert:
 	removed = bt_heap_replace_max(iter->stream_heap, file_stream);
 	assert(removed == file_stream);
 
+	file_stream = bt_heap_maximum(iter->stream_heap);
+	if (file_stream->pos.content_size == 0) {
+		ret = EAGAIN;
+	} else {
+		ret = 0;
+	}
+
 end:
 	return ret;
 }
--

1.8.3.2

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com