projects
/
babeltrace.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Live: let read API detect inactive streams, allow streams without fd
[babeltrace.git]
/
formats
/
ctf
/
ctf.c
diff --git
a/formats/ctf/ctf.c
b/formats/ctf/ctf.c
index 16a7ba0fd66e831b0691b17f75a812ace6964017..122b708f6e74fdfb0b6b6241442c96aca4eb9a39 100644
(file)
--- a/
formats/ctf/ctf.c
+++ b/
formats/ctf/ctf.c
@@
-472,12
+472,16
@@
int ctf_read_event(struct bt_stream_pos *ppos, struct ctf_stream_definition *str
if (unlikely(pos->offset == EOF))
return EOF;
if (unlikely(pos->offset == EOF))
return EOF;
- if (pos->content_size == 0) {
- /* Stream is inactive for now (live reading). */
+ /* Stream is inactive for now (live reading). */
+ if (unlikely(pos->content_size == 0))
return EAGAIN;
return EAGAIN;
- }
- /* Packet only contains headers */
- if (pos->offset == pos->content_size)
+
+ /*
+ * Packet seeked to by ctf_pos_get_event() only contains
+ * headers, no event. Consider stream as inactive (live
+ * reading).
+ */
+ if (unlikely(pos->data_offset == pos->content_size))
return EAGAIN;
assert(pos->offset < pos->content_size);
return EAGAIN;
assert(pos->offset < pos->content_size);
@@
-957,9
+961,10
@@
void ctf_packet_seek(struct bt_stream_pos *stream_pos, size_t index, int whence)
pos->content_size = packet_index->content_size;
pos->packet_size = packet_index->packet_size;
pos->mmap_offset = packet_index->offset;
pos->content_size = packet_index->content_size;
pos->packet_size = packet_index->packet_size;
pos->mmap_offset = packet_index->offset;
- if (packet_index->data_offset < packet_index->content_size) {
+ pos->data_offset = packet_index->data_offset;
+ if (pos->data_offset < packet_index->content_size) {
pos->offset = 0; /* will read headers */
pos->offset = 0; /* will read headers */
- } else if (p
acket_index
->data_offset == packet_index->content_size) {
+ } else if (p
os
->data_offset == packet_index->content_size) {
/* empty packet */
pos->offset = packet_index->data_offset;
whence = SEEK_CUR;
/* empty packet */
pos->offset = packet_index->data_offset;
whence = SEEK_CUR;
@@
-2386,10
+2391,12
@@
int ctf_close_file_stream(struct ctf_file_stream *file_stream)
fprintf(stderr, "Error on ctf_fini_pos\n");
return -1;
}
fprintf(stderr, "Error on ctf_fini_pos\n");
return -1;
}
- ret = close(file_stream->pos.fd);
- if (ret) {
- perror("Error closing file fd");
- return -1;
+ if (file_stream->pos.fd >= 0) {
+ ret = close(file_stream->pos.fd);
+ if (ret) {
+ perror("Error closing file fd");
+ return -1;
+ }
}
return 0;
}
}
return 0;
}
@@
-2421,15
+2428,19
@@
int ctf_close_trace(struct bt_trace_descriptor *tdp)
}
}
ctf_destroy_metadata(td);
}
}
ctf_destroy_metadata(td);
- ret = close(td->dirfd);
- if (ret) {
- perror("Error closing dirfd");
- return ret;
+ if (td->dirfd >= 0) {
+ ret = close(td->dirfd);
+ if (ret) {
+ perror("Error closing dirfd");
+ return ret;
+ }
}
}
- ret = closedir(td->dir);
- if (ret) {
- perror("Error closedir");
- return ret;
+ if (td->dir) {
+ ret = closedir(td->dir);
+ if (ret) {
+ perror("Error closedir");
+ return ret;
+ }
}
free(td->metadata_string);
g_free(td);
}
free(td->metadata_string);
g_free(td);
This page took
0.026307 seconds
and
4
git commands to generate.